diff options
Diffstat (limited to 'jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java')
-rw-r--r-- | jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java index 94f931cb7f..668df07f96 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java @@ -1143,11 +1143,30 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu } } - if (DispatcherType.REQUEST.equals(dispatch) && isProtectedTarget(target)) + switch(dispatch) { - response.sendError(HttpServletResponse.SC_NOT_FOUND); - baseRequest.setHandled(true); - return; + case REQUEST: + if (isProtectedTarget(target)) + { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + baseRequest.setHandled(true); + return; + } + break; + + case ERROR: + // If this is already a dispatch to an error page, proceed normally + if (Boolean.TRUE.equals(baseRequest.getAttribute(Dispatcher.__ERROR_DISPATCH))) + break; + + Object error = request.getAttribute(Dispatcher.ERROR_STATUS_CODE); + // We can just call sendError here. If there is no error page, then one will + // be generated. If there is an error page, then a RequestDispatcher will be + // used to route the request through appropriate filters etc. + response.sendError((error instanceof Integer)?((Integer)error).intValue():500); + return; + default: + break; } // start manual inline of nextHandle(target,baseRequest,request,response); @@ -1654,7 +1673,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu return null; if (_classLoader == null) - return Loader.loadClass(this.getClass(),className); + return Loader.loadClass(className); return _classLoader.loadClass(className); } @@ -2298,7 +2317,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu try { @SuppressWarnings({ "unchecked", "rawtypes" }) - Class<? extends EventListener> clazz = _classLoader==null?Loader.loadClass(ContextHandler.class,className):(Class)_classLoader.loadClass(className); + Class<? extends EventListener> clazz = _classLoader==null?Loader.loadClass(className):(Class)_classLoader.loadClass(className); addListener(clazz); } catch (ClassNotFoundException e) @@ -2391,7 +2410,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu //classloader, or a parent of it try { - Class<?> reflect = Loader.loadClass(getClass(), "sun.reflect.Reflection"); + Class<?> reflect = Loader.loadClass("sun.reflect.Reflection"); Method getCallerClass = reflect.getMethod("getCallerClass", Integer.TYPE); Class<?> caller = (Class<?>)getCallerClass.invoke(null, 2); @@ -2869,7 +2888,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu /** * @param context The context being entered * @param request A request that is applicable to the scope, or null - * @param reason An object that indicates the reason the scope is being entered + * @param reason An object that indicates the reason the scope is being entered. */ void enterScope(Context context, Request request, Object reason); |