Sending response to user when session has timed out

Hello - I would like to send a message to a user saying their session has timed out when their session on the server has expired (basically sending a response without a request - many banking applications do this).  I was thinking to store relevant information from the request in the session when it is created and use HttpSessionBindingListener to trigger the response when the session has expired.  Any ideas on what information I need to get from the request and how I would generate and send the response?  Any better ideas?
sb1977Asked:
Who is Participating?
 
fargoCommented:
well, this can be done other way round. Like in your web page, check for the session identity and see if it is invalid or expired and then show an information page or expiry message to the user. Generally this can be achieved by having either a

Servlet Filter for session check
other examples are explained here, but it will give u pointers about how to use in your case
http://www.onjava.com/pub/a/onjava/2003/11/19/filters.html

OR
having a custom jsp tag lib in each page which first check if the session is valid.
0
 
rrzCommented:
I agree with fargo that you have to do this the other way around.  You could have a frame or an iframe keep refreshing itself or use AJAX.  Look at  
http://java.sun.com/developer/technicalArticles/J2EE/AJAX/     
Basically you will keep sending requests to a servlet or JSP that will check to see if the session is still valid.   rrz

0
 
sb1977Author Commented:
Thanks for your help.  I just did a test on the bank page I was using and found out that the generated message is displayed using Javascript and no new request or response is even generated.  I think I will do this in combination with with server side check that uses the session.isNew() method to see if a session existed at a particular point in the application.

Thanks again!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.