How to auto redirect when session times out


Web tier: servlets, JSP, Web frameworks: How to auto redirect when session times out

  1. How to auto redirect when session times out (1 messages)

    I have been looking at this for quite a while but no luck.

    I am working on a web application using form based authentication. What I try to achieve is to redirect user to a certain page(e.g. login page, or message page showing user the application has timed out)automatically once the application has been idle for certain minutes.

    Right now I can't get this done automatically, but it does take me to login page when I try to click any link on the idled web application and after login I was taken directly to the page I tried to get before login instead of the web application's entry point- this is not what I want.

    Please advise! I appreciate.

  2. I have seen this done before with a refresh timer.

    <meta http-equiv="refresh" content="N">

    where N is the number of seconds. You would set N to be the same number as your session timeout so that the page refreshes when the session times out.

    In JSP you could do something like:

    <meta http-equiv="refresh" content="<%= session.getMaxInactiveInterval() %>">

    This will work with your current setup such that the user will then be redirected to your login page.

    This is not the ideal solution but it's the only one I have come across.

    Hope this helps.