• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to stay logged in?

 
Nishant Vashisth
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys i am making a website in jsp !!
and the login is working fine but the problem is when i go to another page and switch back to the login page it again asks to login !!

how to stay logged in like using session or something else !!
help me out please
 
Louis Bros
Ranch Hand
Posts: 54
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Yes you would have to set a value in the user's session to indicate that they're logged in.

Then in your JSP you could use the JSTL choose tag to either display the login form or not.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While using container-managed security would be best, if you are going to roll your own, then it doesn't make any sense to check for it in a JSP.

Firstly, checking in the JSP is too late; by the time a JSP is executed, the controller has done it's job and may have done something that should not be allowed if not logged in, or if the logged-in user doesn't have appropriate permissions/role.

Also, does it make sense to have to put this check into each and every location that's a possible entry point into the application?

Of course not.

Rather, a servlet filter should be employed that can check the authentication for each request before any other code executes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic