How can I prevent any exceptions occurring to be displayed to the user?
I could instead imagine to just redirect the user to a specific page if any error occures.
Especially I want to prevent HTTP Status 500 view exceptions like this:
javax.faces.application.ViewExpiredException: /index.xhtmlNo saved view state could be found for the view identifier: /index.xhtml
at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:132)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
Why not define custom error pages in your
web.xml? You can specify HTTP error codes as in:…or Java exception classes:
This solution has the advantage of not requiring any extra implementation – except for the error page itself.