tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Parker <mp...@voyanttech.com>
Subject RE: [PATCH] forward instead of redirect for welcome files
Date Tue, 07 Jan 2003 01:33:16 GMT
Here's the new version of the patch. the code to redirect if there is no
trailing slash remains untouched, but it now forwards if there is a
trailing slash. i've included more context to avoid potential confusion:


--- DefaultServlet.java	2003-01-03 16:20:23.000000000 -0700
+++ DefaultServlet.java.new	2003-01-06 18:27:25.000000000 -0700
@@ -939,46 +939,42 @@
         // If the resource is a collection (aka a directory), we check
         // the welcome files list.
         if (resourceInfo.collection) {
 
             if (!request.getRequestURI().endsWith("/")) {
                 String redirectPath = path;
                 String contextPath = request.getContextPath();
                 if ((contextPath != null) &&
(!contextPath.equals("/"))) {
                     redirectPath = contextPath + redirectPath;
                 }
                 if (!(redirectPath.endsWith("/")))
                     redirectPath = redirectPath + "/";
                 redirectPath = appendParameters(request, redirectPath);
                 response.sendRedirect(redirectPath);
                 return;
             }
 
             ResourceInfo welcomeFileInfo = checkWelcomeFiles(path,
resources);
             if (welcomeFileInfo != null) {
                 String redirectPath = welcomeFileInfo.path;
-                String contextPath = request.getContextPath();
-                if ((contextPath != null) &&
(!contextPath.equals("/"))) {
-                    redirectPath = contextPath + redirectPath;
-                }
                 redirectPath = appendParameters(request, redirectPath);
-                response.sendRedirect(redirectPath);
+               
request.getRequestDispatcher(redirectPath).forward(request, response);
                 return;
             }
 
         } else {
 
             // Checking If headers
             boolean included =
                 (request.getAttribute(Globals.CONTEXT_PATH_ATTR) !=
null);
             if (!included 
                 && !checkIfHeaders(request, response, resourceInfo)) {
                 return;
             }
 
         }
 
         // Find content type.
         String contentType =
             getServletContext().getMimeType(resourceInfo.path);
 
         Vector ranges = null;



--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message