This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Servlets and the fly likes how to return a page to infor client when the session time out ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to return a page to infor client when the session time out ?" Watch "how to return a page to infor client when the session time out ?" New topic
Author

how to return a page to infor client when the session time out ?

luxica peng
Greenhorn

Joined: Jun 02, 2005
Posts: 5
Hello,everyone:
I have seen on some web a page may return to browser when the session time out.I only know the HttpSessionListner has this function.but we often use a response to return page,from the listner we can get the session by the HttpSessionEvent,but how can I get the response?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You don't need a listener for this.

When the user logs in, bind an object to session (let's call it 'userBean').
With every subsequent request, check for the existence of this object.
If request.getSession().getAttribute("userBean") is null then the user has either not logged in or has let their session time out.
In that case forward or redirect to the login page.

A filter makes it easy to put this checking fuctionality in front of every request without having to update all of your servlets.

I have an example app that does this on:
http://simple.souther.us/not-so-simple.html
Look for SessionMonitor


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
luxica peng
Greenhorn

Joined: Jun 02, 2005
Posts: 5
this is valuably.thanks,Ben.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to return a page to infor client when the session time out ?
 
Similar Threads
Head First Session management : doubts
Session and RequestDispatcher question
Return a pdf and refresh the calling page
Session Tracking
Multiple Forms, Multiple Submissions