Redirecting after session expires

November 30

i have a user session object which implements HttpSessionBindingListener.
what i would like it to do is when the unBound method is triggered, i want it to be directed to a logoff page. This process was created to automatically log off the users which closed down their browsers.
However, when the session expires and this object is unBound, i have not been able to find a way to get it to redirect ot the logoff page.
is there any way to do this??
Or possibly some other way of listening for the session expiration and to redirect to the logoff page??
Here is the code of the session object.
public class UserSession implements HttpSessionBindingListener{  
private String userid;
public String getUserid(){
return userid;
public void setUserid(String value){
userid = value;
public void valueBound(HttpSessionBindingEvent event)
public void valueUnbound(HttpSessionBindingEvent event)
RequestDispatcher rd = request.getRequestDispatcher("logoff");
rd.forward(request, response);



The object that is in session and implementing HttpSessionBindingListener can only be existing with in HttpSession boundary, and There would be only one response if there is a request(Http primary rule),
As I have been using this(servlet 2.3) kind of approach in my work, I can assure that there is no chance of sending/redirecting a page to browser in this scene.
Let's think in this way..
Session will be expired in the web server only and only Servletcontext/webserver knows when it is going to be expired.. to send a page u need request( request.getRequestDispatcher("")..) object or response ( response.sendRedirect("")) objects.. So how would we get these objects in the session.
and as HTTP follows the stateless behaviour, Server would never know whom it should send page. unless there( in server) is some one (request) waiting to recieve this response..
For your question. I can suggest use page refresh meta tag that would call when certan time( 5 min) expires that means user is inactive with the application...
Hope this can help you..

View 8 Replies


  1. what hv to do after stolen kaptop
  2. Nokia 6120c midp certificate download
  3. KE30 and SAP
  4. mass approval fk09
  5. H8N4
  6. R90M
  7. gladpng
  8. supposex7v
  9. influencev66
  10. attachedyxc
Copyrights 2019 Fcffair BigData Resource, All rights reserved