• Post Reply Bookmark Topic Watch Topic
  • New Topic

Validating Username and Password in JSP  RSS feed

 
Shyam Kasthala
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have a JSP Registration page where the user inserts the username,password,address etc into the database.After submitting the page,the login page appears where i have to enter the username and password.Now i want to check the username and password i entered in the text boxes with the values in the database.I they match then the user should go the next page otherwise he should get an error msg.How should i validate it.Please some one give me the code for it.I have tried it in the servlet from the database side with the query as shown below but i am not able to get it.Is my query right?If not, how should i do it.If the query is right, where i am going wrong?please anyone tell me how can i do it from jsp?

"select * from mgsch.register where user_name='"+u+"' and pass_word='"+p+"' "

mgsch.register is the table where the i insert the values from the registration page.
Thank you.
 
Eddy Lee Sin Ti
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be helpful to post your codes up.
 
pradheesh manohar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i hope this would help you

select userid,password from tablename where userid=" userid field ";

while ( rs.next() ) // this will step through our data row-by-row
{
if(rs.getString(2).trim().equals( password field ))
{
//forward to success page
}
//forward to failure page
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!