tags:

views:

72

answers:

1

hi, I need to come out of the application after some inactivity session I tried using session.invalidate(); but it is not working as i am using basic authentication and i redirected to JSP page where it asks for login again but it is not asking any login credentials directly logging in to application The only way to logout with basic authentication is to close the Webbrowser. I need an API such that after inactivty say 10 mins it should redirect to one JSP page without closing the browser like banking sites will display session expired please login again

Thanks in advance, Satya

A: 

Make use of meta refresh header in combination with HttpSession#getMaxInactiveInterval(). It returns the remaining lifetime of the HttpSession in seconds and that's exactly what you need in a meta refresh header.

<meta http-equiv="refresh" content="${pageContext.session.maxInactiveInterval};url=expired.jsp">

Include this header in your HTML <head>. If the session timeout has been reached, then the browser will automatically redirect the page to the specified url, which is expired.jsp in above example.

BalusC