I am learning j2ee and started with a simple login and logout application. I would like to gracefully handle javax.faces.application.ViewExpiredException upon session timeout. Looking at several posts, I tried to handle it via web.xml using the below.
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/index.xhtml</location>
</error-page>
However, this is still resulting in the same exception in the back end. Below are the steps I am repeating to recreate the issue:
- Login from index.xhtml. This lands user to welcome.xhtml with a h:commandbutton for logout
- Let the session expire
- Click the logout button. If session has expired user should be redirected to index.xhtml
Any idea on what I am missing? Based on my reading of the many posts, this seems to be the correct way.
This is not working because
ViewExpiredException
is wrapped in aServletException
in JSF.You can try two different solutions:
1- web.xml with ServletException
2- faces-config.xml