aspose file tools*
The moose likes JDBC and the fly likes problem validating user login using jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "problem validating user login using jsp" Watch "problem validating user login using jsp" New topic
Author

problem validating user login using jsp

joseph okon
Ranch Hand

Joined: Dec 07, 2004
Posts: 63
I know something is wrong:
am trying to validate user input(loginName and password).

my html code


my jsp code:


my sql table:


it do not work that is
(1)it can't validate the login user.
(2)it dosen't iterate inside the table to get the userName.

can somebody help me out?
thanks to you all.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18868
    
    8

Well, first of all it's bad form to have that sort of code in a JSP. Put it in a servlet, and forward to the JSP once you decide what you want to do.

And don't forward until you have decided. Your code there forwards once for every record in the table. That's a bad idea and not likely to produce the correct results. It would be better to have a Select statement with a where-clause which returns one record for a correct login and zero records for an incorrect login.

But most of all, your code here

compares the data read from the database to certain string constants instead of comparing it to the variables where you saved the request parameters.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

(2)it dosen't iterate inside the table to get the userName.


does this statements print user and password or else?



or it's a good practice to always close any database connection you open within a finally block. Leaving connections open is one of the biggest sources of memory leaks in large systems.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

and of course paul suggested you the best for the validation, in this way the code will be more simpler and save up yourself to write extra code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem validating user login using jsp