Code cleanups for direct RequestDispatcher access

This commit is contained in:
Greg Wilkins 2013-06-24 13:13:03 +10:00
parent b2b2ce25fc
commit 068e67a8df
2 changed files with 10 additions and 8 deletions

View File

@ -26,6 +26,7 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.Locale;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
@ -341,10 +342,10 @@ public class Response implements HttpServletResponse
error_handler = _connection.getConnector().getServer().getBean(ErrorHandler.class);
if (error_handler!=null)
{
request.setAttribute(Dispatcher.ERROR_STATUS_CODE,new Integer(code));
request.setAttribute(Dispatcher.ERROR_MESSAGE, message);
request.setAttribute(Dispatcher.ERROR_REQUEST_URI, request.getRequestURI());
request.setAttribute(Dispatcher.ERROR_SERVLET_NAME,request.getServletName());
request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE,new Integer(code));
request.setAttribute(RequestDispatcher.ERROR_MESSAGE, message);
request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI, request.getRequestURI());
request.setAttribute(RequestDispatcher.ERROR_SERVLET_NAME,request.getServletName());
error_handler.handle(null,_connection.getRequest(),_connection.getRequest(),this );
}
else

View File

@ -38,6 +38,7 @@ import javax.servlet.AsyncContext;
import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@ -562,8 +563,8 @@ public class ServletHandler extends ScopedHandler
if (!response.isCommitted())
{
request.setAttribute(Dispatcher.ERROR_EXCEPTION_TYPE,th.getClass());
request.setAttribute(Dispatcher.ERROR_EXCEPTION,th);
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE,th.getClass());
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION,th);
if (th instanceof UnavailableException)
{
UnavailableException ue = (UnavailableException)th;
@ -588,8 +589,8 @@ public class ServletHandler extends ScopedHandler
// TODO httpResponse.getHttpConnection().forceClose();
if (!response.isCommitted())
{
request.setAttribute(Dispatcher.ERROR_EXCEPTION_TYPE,e.getClass());
request.setAttribute(Dispatcher.ERROR_EXCEPTION,e);
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE,e.getClass());
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION,e);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
else