Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Trying to make sense of login.jsp  RSS feed

 
Benny Choi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I've started playing with JSP and JDBC and had a question.
You see, I've got a login.jsp that processes FORM info from a login.html. When the user POSTS the form, login.jsp checks to see if the username/pwd requested is in a hsql dB. If it is, login.jsp creates a SESSION and redirects the username:SESSION to a welcome.jsp. If login.jsp does not find the information, it does nothing. Absolutely nothing.
I'd like to come up with a better scheme than nothing on a failed login attempt. One problem is figuring out where, and what, to HttpRespond with for someone trying to login.
Any suggestions?
benny
 
Tomas Nilson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can simply redirect the user to an information page telling him that the log in didn't work.
Why do you set the username to SESSION? Won't you need it (the right username) in the future??
/Tomas
 
Benny Choi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomas,
You have a point about the "username:SESSION" language. I should be less euphemistic and more careful with my choice of words (especially in this forum). What I should have said: myHttpSession.putValue("userName", userName).
Taking your advice, I've decided to put this logic into the same control structure for successful attempts.
Something like...
if(userName == null) ? LoginBean.sendHere("/bad_login.jsp") : LoginBean.sendHere("/welcome.jsp");
benny
 
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!