It's not a secret anymore!*
The moose likes JSP and the fly likes how to redirect to login page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how to redirect to login page" Watch "how to redirect to login page" New topic
Author

how to redirect to login page

suresh pulapally
Ranch Hand

Joined: Mar 15, 2005
Posts: 47
we are developing a web application on bea.our requirement is after session timeout any request should be forward to login page(i set session timeout in web.xml),how to know that session is timeout and how to redirect it login page.

thanx

[Bear edit: added meaningful title]
[ May 15, 2005: Message edited by: Bear Bibeault ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

On a sucessfull login, bind an object to the user's session.
With each hit to any of your other pages (a ServletFilter is perfect for this) check the session for the existence of this object.
If it's there, you know the user is currently logged in.
If it's null, you know they're not. Redirect them to the login page.
[ May 15, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
suresh pulapally
Ranch Hand

Joined: Mar 15, 2005
Posts: 47
thanx,
i will try this.
Neerajplus Kumarplus
Greenhorn

Joined: May 05, 2005
Posts: 5
Here is an example.

http://neeraj.name/2005/05/03/javascript-to-perform-a-client-side-redirect-upon-session-expiration/


----------------------------------<br />Neeraj Kumar<br /><a href="http://www.neeraj.name" target="_blank" rel="nofollow">www.neeraj.name</a>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to redirect to login page