ErrorPage errorPage = findErrorPage(context, realError);
if (errorPage != null) {
response.setAppCommitted(false);
ServletRequest sreq = request.getRequest();
ServletResponse sresp = response.getResponse();
sreq.setAttribute
(ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
errorPage.getLocation());
sreq.setAttribute(ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
new Integer(ApplicationFilterFactory.ERROR));
sreq.setAttribute
(Globals.STATUS_CODE_ATTR,
new Integer(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
sreq.setAttribute(Globals.ERROR_MESSAGE_ATTR,
throwable.getMessage());
sreq.setAttribute(Globals.EXCEPTION_ATTR,
realError);
Wrapper wrapper = request.getWrapper();
if (wrapper != null)
sreq.setAttribute(Globals.SERVLET_NAME_ATTR,
wrapper.getName());
if (sreq instanceof HttpServletRequest)
sreq.setAttribute(Globals.EXCEPTION_PAGE_ATTR,
((HttpServletRequest) sreq).getRequestURI());
sreq.setAttribute(Globals.EXCEPTION_TYPE_ATTR,
realError.getClass());
if (custom(request, response, errorPage)) {
try {
sresp.flushBuffer();
} catch (IOException e) {
log("Exception Processing " + errorPage, e);
}
}
} else {
// A custom error-page has not been defined for the exception
// that was thrown during request processing. Check if an
// error-page for error code 500 was specified and if so,
// send that page back as the response.
ServletResponse sresp = (ServletResponse) response;
if (sresp instanceof HttpServletResponse) {
((HttpServletResponse) sresp).setStatus(
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
// The response is an error
response.setError();