Using sendError with JSF
843842Jun 4 2004 — edited Jun 4 2004I would like to display an error page when I run into some exception in a JSF page. I have configured web.xml as follows:
<error-page>
<error-code>100</error-code>
<location>/serverError.jsp</location>
</error-page>
Then, in my code, when I get an exception, I execute the following code:
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response =
(HttpServletResponse) context.getExternalContext().getResponse();
try {
response.sendError(100);
}
catch (IOException ex) {
log.error("Exception trying to handle server error: " +
"original exception = " + e);
}
However, when I execute this code, the server does not display my error page. I do see my error page on uncaught exception (I have also a error rule on error code 500). Is there anything special that should be done to make the error page handling in JSF?
Martin