• Post Reply Bookmark Topic Watch Topic
  • New Topic

Login password  RSS feed

 
Olliver Lim Kam Sian
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

Can anyone provide me with simple code for login and password.I need to use it in client/server connection.
thanks

Olliver
 
Adam Schaible
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer to your question can be found here:

How to ask a good question
 
Olliver Lim Kam Sian
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well at least help me get started, which class to use for example. The thing is i need a seperate .java file which is the login and password code so i can call for before the client connects to the network, all i'm asking is that if you have something in hand, if you can post it so I can work on it!Im not asking you guys to do the whole thing for me. Just help me get started


thanks Olliver
 
chloe wong
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a simple example of doing it with Spring and JSF

Login.jsp
---------
.....

value="#{loginBean.username}"
....
value="#{loginBean.password}"
.....
action="#{loginBean.loginAction}"

loginBean
--------
..
private String username;
private String password;
public String getUsername(){return username;}
public void setUsername(String username){ this.username=username;}
public String getPassword(){return password;}
public void setPassword(String password){this.password = password;
...


public String loginAction()
{
String usernameTxt = this.getUsername();
String passwordTxt = this.getPassword();
try
{
//get the password from DB
...
//then compare with the one you get from the JSP page
//if not match, return to login.jsp
if(...)
{
return "LOGIN_PAGE";
}
}
catch(Exception e)
{
e.printStackTrace();
return "ERROR_PAGE";
}
return "LANDING_PAGE";
}
 
chloe wong
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for better secure, you can do some javascript validation checking.

Normally password are stored in DB as encrypted, not plain text.
So, in order to cehck the mactching, you can encrypt (MD5) your password frm login, then oni compare wtih the passwrod retrieve from DB.

Good Luck
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by chloe wong:
for better secure, you can do some javascript validation checking.

JavaScript is publically available to the client and may be turned off. It is not a good candiate technology to choose to implement any security or validation functionality (beyond suggestions to the user that may preclude the need for a server round trip).
[ October 26, 2007: Message edited by: Paul Sturrock ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!