Sending response to user when session has timed out

Posted on 2006-05-05
Last Modified: 2010-04-01
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?
Question by:sb1977
    LVL 11

    Accepted Solution

    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

    having a custom jsp tag lib in each page which first check if the session is valid.
    LVL 27

    Expert Comment

    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    
    Basically you will keep sending requests to a servlet or JSP that will check to see if the session is still valid.   rrz


    Author Comment

    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!

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    It can often be challenging to stay relevant in the rapidly evolving world of technology. This can make recruiting talent difficult for companies of all sizes.
    For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now