From: timw Date: Mon, 4 Oct 2010 20:37:11 +0000 (+0000) Subject: More fixes for https://issues.apache.org/bugzilla/show_bug.cgi?id=50026 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a0b02786738019e641fa89c3e8668869f4b9e0c4;p=tomcat7.0 More fixes for https://issues.apache.org/bugzilla/show_bug.cgi?id=50026 Calculating path prefix used in listings correctly so links in listings produced by WebdavServlet mounted to a subpath are correct. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1004415 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java b/java/org/apache/catalina/servlets/DefaultServlet.java index 5e5b126d8..30af597fe 100644 --- a/java/org/apache/catalina/servlets/DefaultServlet.java +++ b/java/org/apache/catalina/servlets/DefaultServlet.java @@ -374,6 +374,18 @@ public class DefaultServlet /** + * Determines the appropriate path to prepend resources with + * when generating directory listings. Depending on the behaviour of + * {@link #getRelativePath(HttpServletRequest)} this will change. + * @param request the request to determine the path for + * @return the prefix to apply to all resources in the listing. + */ + protected String getPathPrefix(final HttpServletRequest request) { + return request.getContextPath(); + } + + + /** * Process a GET request for the specified resource. * * @param request The servlet request we are processing @@ -890,8 +902,7 @@ public class DefaultServlet if (serveContent) { // Serve the directory browser - renderResult = - render(request.getContextPath(), cacheEntry); + renderResult = render(getPathPrefix(request), cacheEntry); } } diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java b/java/org/apache/catalina/servlets/WebdavServlet.java index fb4054ca8..fe2f5918e 100644 --- a/java/org/apache/catalina/servlets/WebdavServlet.java +++ b/java/org/apache/catalina/servlets/WebdavServlet.java @@ -428,6 +428,20 @@ public class WebdavServlet /** + * Determines the prefix for standard directory GET listings. + */ + @Override + protected String getPathPrefix(final HttpServletRequest request) { + // Repeat the servlet path (e.g. /webdav/) in the listing path + String contextPath = request.getContextPath(); + if (request.getServletPath() != null) { + contextPath = contextPath + request.getServletPath(); + } + return contextPath; + } + + + /** * OPTIONS Method. * * @param req The request