I want to display the default Tomcat error page in JSF 2.0 (MyFaces) application when exception is thrown.
I added following lines to web.xml:
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/ErrorHandler</location>
</error-page>
<context-param>
<param-name>org.apache.myfaces.ERROR_HANDLING</param-name>
<param-value>false</param-value>
</context-param>
And here is ErrorHandler servlet:
public class ErrorHandler extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
"Error");
}
}
But instead of the default Tomcat error page an empty page is displayed with error code 500.
When I try to access ErrorHandler servlet directly through URL, it works OK: Tomcat error page is displayed.
So I guess the reason is JSF error handling mechanism? What am I doing wrong?