tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Parker <mp...@voyanttech.com>
Subject [PATCH] forward instead of redirect for welcome files
Date Sat, 04 Jan 2003 00:03:27 GMT
I'd like to suggest that catalina perform a forward, rather than a
redirect, for requests that end with '/'. With a redirect, special
configuration is necessary for proxy servers to work correctly. Also, a
forward doesn't require an additional round trip to the client--a
redirect must get back to the client and the client then issues a new
request. I've tested this under Linux. Thanks!

Matt


--- DefaultServlet.java	2003-01-03 16:20:23.000000000 -0700
+++ DefaultServlet.java.new	2003-01-03 16:20:18.000000000 -0700
@@ -942,26 +942,18 @@
 
             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);
+                request.getRequestDispatcher(redirectPath).forward(request, response);
                 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;
             }




--
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