diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java index 2c49641362c..3e7e5a078e9 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java @@ -447,7 +447,9 @@ public class ResourceHandler extends HandlerWrapper // handle directories if (resource.isDirectory()) { - if (!request.getPathInfo().endsWith(URIUtil.SLASH)) + String pathInfo = request.getPathInfo(); + boolean endsWithSlash=(pathInfo==null?request.getServletPath():pathInfo).endsWith(URIUtil.SLASH); + if (!endsWithSlash) { response.sendRedirect(response.encodeRedirectURL(URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH))); return;