Link to home
Start Free TrialLog in
Avatar of sb1977
sb1977

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of fargo
fargo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rrz
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

Avatar of sb1977
sb1977

ASKER

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!