title: Handling 'session expired' in JSF web application, running in JBoss AS 5
body: <p>This question is related to my other question "<a href="https://stackoverflow.com/questions/1026846/how-to-redirect-to-login-page-when-session-is-expired-in-java-web-application">How to redirect to Login page when Session is expired in Java web application?</a>". Below is what I'm trying to do:</p>
  
  <ol>
  <li>I've a JSF web application running on JBoss AS 5</li>
  <li>When the user is inactive for, say 15 minutes, I need to log out the user and redirect him to the login page, if he is trying to use the application after the session has expired.</li>
  <li>So, as suggested in '<a href="http://www.jroller.com/hasant/entry/jsf_logout_and_redirect_user" rel="nofollow noreferrer">JSF Logout and Redirect</a>', I've implemented a filter which checks for the session expired condition and redirects the user to a session-timed-out.jsp page, if the session has expired.</li>
  <li>I've added SessionExpiryCheckFilter on top of all other filter definitions in web.xml, so that my session expiry check will get the first hit always.</li>
  </ol>
  
  <p>Now comes the <strong>challenge I'm facing</strong>. Since I'm using JBoss AS, when the session expired, JBoss automatically redirects me to the login page (note that the session expiry check filter is not invoked). So, after I log-in, my SessionExpiryCheckFilter intercepts the request, and it sees a session is available. But, it throws the exception <code>javax.faces.application.ViewExpiredException: viewId:/mypage.faces - View /mypage.faces could not be restored.</code></p>
  
  <p>Have anyone faced this issue before? Any ideas to solve this issue?</p>