This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem validating user login using jsp

 
joseph okon
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20196
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1324
Android Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(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.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic