This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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>
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to redirect to login page
 
Similar Threads
session timeout implementation
Handling session timeout and session invalidate differently
Redirecting to Login page on session timeout!!
How Do I Use Servlet Filter To Check Session Time-out?
session is not invalidating