Redirecting the web application to its home page when session is timeout

One of the requirements that might be needed in web applications is redirecting the web application to its home page when the user session is timeout.

There are many approaches that can be followed to solve this problem, like using the JavaScript setTimeout() method to refresh the page every period of time and a servlet filter that check whether the session is expired to redirect the application to its home page.

Although this solution is applicable but will really induce massive amounts of stomach acid to the web application and to its maintaince.

After digging for a while in the problem, I found this smart approach; all what you should do is just place the following meta tag inside the <head> tag of your JSPs :

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