
05-14-2009, 02:32 AM
|
|
Member
|
|
Join Date: Feb 2009
Posts: 27
Rep Power: 0
|
|
Developing a logon screen
Hey, i want to create a java login applet, which can be embedded in to a web page and send information such as user name and password to a servelet to be validated by a database.
Are there any tutorials around showing this? I have had a look on the net and i cant find anything. I can create a simple login which has the user name and password embedded in to the code but im totally lost when creating a login which communicates wiht a servlet then on to a database.
|
|

05-14-2009, 04:30 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
|
|
JSP is much better than Applet for your requirement. What's the point of use Applet in your project?
JSP Tutorial - Java Server Pages Tutorials
|
|

05-14-2009, 12:46 PM
|
|
Member
|
|
Join Date: Feb 2009
Posts: 27
Rep Power: 0
|
|
|
Been told we must use a applet and servlet
|
|

05-14-2009, 07:06 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
|
|
|
I think it's better to read more about JSP/Servlet by you before doing this.
JSP are actually Servlet. In backend JSP are compiled into Servlet. Best way is, you can keep member details in a database and validate in a Servlet.
|
|

05-14-2009, 07:11 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
|
|
Here is a simple example. Just look at it. May be it can helpful to you.
JSP Login Page
|
|

05-15-2009, 03:01 AM
|
|
Member
|
|
Join Date: Feb 2009
Posts: 27
Rep Power: 0
|
|
Thx, i have the applet passing a string (username and password) to the servlet, and i have a seperate servlet which can read from a database, (for simplicity im using access database) however i cant think how to query a username or password against a database .
|
|

05-15-2009, 06:31 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
|
|
|
Ok, what you have tried(the query) to deal with the user name and the password?
|
|

05-15-2009, 11:24 AM
|
|
Member
|
|
Join Date: Feb 2009
Posts: 27
Rep Power: 0
|
|
|
well what i have noticed is when you send the data, user name and password, it comes through as one string, so im trying to split that up first
|
|

05-15-2009, 01:17 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
|
|
|
Code:
|
<body>
<%
String url = "jdbc:odbc:userDSN";
String username="";
String password="";
Connection conn=null;
String classPath = "sun.jdbc.odbc.JdbcOdbcDriver";
String usernm = username; // Validating user name
String passwrd = password; // Validating password
try{
Class.forName(classPath);
conn = DriverManager.getConnection(url,username,password);
}catch(Exception exc){
out.println(exc.toString());
}
%>
<%
Statement stm=null;
ResultSet rst=null;
stm= conn.createStatement();
String query= "SELECT userID, password FROM user WHERE userID =" +usernm;
rst = stm.executeQuery(query);
%>
<%= rst.getString("userID") %>
<%= rst.getString("password") %>
<%
if (usernm.equals(userID) && passwrd.equals(password)) { %>
<jsp:forward page = "index.jsp"></jsp:forward>
<% } else { %>
<jsp:forward page = "login_handle.jsp"></jsp:forward>
<% }
rst.close();
stm.close();
conn.close();
%>
</body> |
Here is a simple code I've with me on one of my application, just a part of it. I don't know how far it's clear to you. Have a look at it and try to understand what's going on there.
|
|

05-15-2009, 01:17 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
|
|
I think it's much better to read the following page yourself.
Understanding Login Authentication
|
|

05-16-2009, 01:28 AM
|
|
Member
|
|
Join Date: Feb 2009
Posts: 27
Rep Power: 0
|
|
|
Cool, ive managed to split the string up in to user name and password, now all i need is to connect to an access database and compare with the results which are in that
|
|

05-16-2009, 01:51 AM
|
 |
Senior Member
|
|
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
|
|
|
It's a good idea to only store and transmit secure hashes of passwords, rather than the passwords themselves.
|
|

05-16-2009, 02:26 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
|
|
|
I agreed with you OD. I just trying to point-out in my code just the model of login page. Actually at the very first step, he/she don't have an idea what the technology need to use and lot more to understand.
That's why I point the hard corded credentials there.
|
|

05-16-2009, 12:15 PM
|
|
Member
|
|
Join Date: Feb 2009
Posts: 27
Rep Power: 0
|
|
|
dont worry about password security i just need once the variables have been sent to connect to a database and compare with what is in the database. If they pass that test, then i can gain access and go in
|
|

05-16-2009, 08:22 PM
|
 |
Senior Member
|
|
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
|
|
|
But if they're not hashed, so can everyone else.
|
|

05-16-2009, 09:59 PM
|
|
Member
|
|
Join Date: Feb 2009
Posts: 27
Rep Power: 0
|
|
|
what do you mean by hashed?
|
|

05-16-2009, 10:11 PM
|
 |
Senior Member
|
|
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
|
|
|
|
|

05-16-2009, 10:20 PM
|
|
Member
|
|
Join Date: Feb 2009
Posts: 27
Rep Power: 0
|
|
|
oh rite, ok, i really want to keep this simple, i dont really need anything like that in there
|
|

05-17-2009, 04:28 AM
|
 |
Senior Member
|
|
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
|
|
|
Just as long as you know that a system where plaintext passwords are transmitted and stored is in no way secure.
|
|

05-17-2009, 11:02 AM
|
|
Member
|
|
Join Date: Feb 2009
Posts: 27
Rep Power: 0
|
|
|
yep :-) maybe when i get it working i can look in to that, but for now i need to get it logging in first.
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +2. The time now is 04:36 PM.
|
|