I have a JSF 2 application and configured the following in web.xml
:
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/error.html</location>
</error-page>
For testing purposes I have the following code in a @SessionScoped
class within an init Method annotated with @PostConstruct
in order to let the session quickly expire:
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
HttpSession session = (HttpSession) ec.getSession(false);
session.setMaxInactiveInterval(5);
Now, when I have an h:commandButton
with outcome = "somepage.jsf"
then a click after the 5s will redirect to the error page.
When I instead call some bean action or putting the page name in action on the very same button using the action
attribute , I see the ViewExpiredException
in the server's log, but no redirection occurs.
Why is that so? And how to generally redirect to another page no matter which action took place after the session expires?