tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets DefaultServlet.java
Date Fri, 23 Mar 2001 02:55:44 GMT
remm        01/03/22 18:55:44

  Modified:    catalina/src/share/org/apache/catalina/servlets
                        DefaultServlet.java
  Log:
  - Now adding the parameters before sending a redirect.
    Bug reported by Stefan Schmidt <stefan at schmidt1.de>
  
  Revision  Changes    Path
  1.31      +41 -6     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java
  
  Index: DefaultServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- DefaultServlet.java	2001/03/18 06:36:13	1.30
  +++ DefaultServlet.java	2001/03/23 02:55:44	1.31
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
1.30 2001/03/18 06:36:13 remm Exp $
  - * $Revision: 1.30 $
  - * $Date: 2001/03/18 06:36:13 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
1.31 2001/03/23 02:55:44 remm Exp $
  + * $Revision: 1.31 $
  + * $Date: 2001/03/23 02:55:44 $
    *
    * ====================================================================
    *
  @@ -122,7 +122,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.30 $ $Date: 2001/03/18 06:36:13 $
  + * @version $Revision: 1.31 $ $Date: 2001/03/23 02:55:44 $
    */
   
   public class DefaultServlet
  @@ -1047,7 +1047,9 @@
           if (resourceInfo.collection) {
   
   	    if (!request.getRequestURI().endsWith("/")) {
  -	        response.sendRedirect(request.getRequestURI() + "/");
  +                String redirectPath = request.getRequestURI() + "/";
  +                redirectPath = appendParameters(request, redirectPath);
  +	        response.sendRedirect(redirectPath);
   		return;
   	    }
   
  @@ -1058,7 +1060,8 @@
                   if ((contextPath != null) && (!contextPath.equals("/"))) {
                       redirectPath = contextPath + redirectPath;
                   }
  -                response.sendRedirect(rewriteUrl(redirectPath));
  +                redirectPath = appendParameters(request, redirectPath);
  +                response.sendRedirect(redirectPath);
                   return;
               }
               
  @@ -1364,6 +1367,38 @@
           }
           
           return result;
  +    }
  +
  +
  +    /**
  +     * Append the request parameters to the redirection string before calling
  +     * sendRedirect.
  +     */
  +    protected String appendParameters(HttpServletRequest request, 
  +                                      String redirectPath) {
  +        
  +        StringBuffer result = new StringBuffer(rewriteUrl(redirectPath));
  +        
  +        Enumeration enum = request.getParameterNames();
  +        if (enum.hasMoreElements())
  +            result.append("?");
  +        
  +        while (enum.hasMoreElements()) {
  +            String name = (String) enum.nextElement();
  +            String[] values = request.getParameterValues(name);
  +            for (int i = 0; i < values.length; i++) {
  +                result.append(rewriteUrl(name));
  +                result.append("=");
  +                result.append(rewriteUrl(values[i]));
  +                if (i < (values.length - 1))
  +                    result.append("&");
  +            }
  +            if (enum.hasMoreElements())
  +                result.append("&");
  +        }
  +        
  +        return result.toString();
  +        
       }
   
   
  
  
  

Mime
View raw message