tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <h...@gefionsoftware.com>
Subject Re: [PATCH] forward instead of redirect for welcome files
Date Mon, 06 Jan 2003 19:14:11 GMT
Matt Parker wrote:
> 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!

You mean requests that do _not_ end with '/', right? Unfortunatly,
you must do a redirect in this case so that the browser can resolve
relative paths in the page correctly. If you use a forward, it can't
do so correctly.

Hans

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

-- 
Hans Bergsten                                <hans@gefionsoftware.com>
Gefion Software                       <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at                                    <http://TheJSPBook.com/>


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