craigmcc    02/02/15 17:07:11

  Modified:    catalina/src/share/org/apache/catalina/servlets
                        InvokerHttpRequest.java InvokerServlet.java
  Log:
  Wrap the getPathTranslated() method of the wrapped request used the first
  time a particular servlet is invoked, so that it returns the correct value
  on the first call.  It already returned the correct value on all subsequent
  calls, which bypass the invoker.
  
  PR: Bugzilla #6480
  Submitted by: Amar Mattey <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  1.4       +34 -4     
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/InvokerHttpRequest.java
  
  Index: InvokerHttpRequest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/InvokerHttpRequest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InvokerHttpRequest.java   22 Jul 2001 20:25:11 -0000      1.3
  +++ InvokerHttpRequest.java   16 Feb 2002 01:07:11 -0000      1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/InvokerHttpRequest.java,v
 1.3 2001/07/22 20:25:11 pier Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/07/22 20:25:11 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/InvokerHttpRequest.java,v
 1.4 2002/02/16 01:07:11 craigmcc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/02/16 01:07:11 $
    *
    * ====================================================================
    *
  @@ -88,7 +88,7 @@
    * to the servlet, because a new servlet mapping will have been created.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2001/07/22 20:25:11 $
  + * @version $Revision: 1.4 $ $Date: 2002/02/16 01:07:11 $
    */
   
   class InvokerHttpRequest extends HttpServletRequestWrapper {
  @@ -106,6 +106,7 @@
   
           super(request);
           this.pathInfo = request.getPathInfo();
  +        this.pathTranslated = request.getPathTranslated();
           this.requestURI = request.getRequestURI();
           this.servletPath = request.getServletPath();
   
  @@ -129,6 +130,12 @@
   
   
       /**
  +     * The translated path information for this request.
  +     */
  +    protected String pathTranslated = null;
  +
  +
  +    /**
        * The request URI for this request.
        */
       protected String requestURI = null;
  @@ -161,6 +168,17 @@
   
   
       /**
  +     * Override the <code>getPathTranslated()</code> method of the
  +     * wrapped request.
  +     */
  +    public String getPathTranslated() {
  +
  +        return (this.pathTranslated);
  +
  +    }
  +
  +
  +    /**
        * Override the <code>getRequestURI()</code> method of the wrapped request.
        */
       public String getRequestURI() {
  @@ -203,6 +221,18 @@
       void setPathInfo(String pathInfo) {
   
           this.pathInfo = pathInfo;
  +
  +    }
  +
  +
  +    /**
  +     * Set the translated path info for this request.
  +     *
  +     * @param pathTranslated The new translated path info
  +     */
  +    void setPathTranslated(String pathTranslated) {
  +
  +        this.pathTranslated = pathTranslated;
   
       }
   
  
  
  
  1.15      +10 -6     
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/InvokerServlet.java
  
  Index: InvokerServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/InvokerServlet.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- InvokerServlet.java       20 Sep 2001 23:34:42 -0000      1.14
  +++ InvokerServlet.java       16 Feb 2002 01:07:11 -0000      1.15
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/InvokerServlet.java,v
 1.14 2001/09/20 23:34:42 remm Exp $
  - * $Revision: 1.14 $
  - * $Date: 2001/09/20 23:34:42 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/InvokerServlet.java,v
 1.15 2002/02/16 01:07:11 craigmcc Exp $
  + * $Revision: 1.15 $
  + * $Date: 2002/02/16 01:07:11 $
    *
    * ====================================================================
    *
  @@ -87,7 +87,7 @@
    * in the web application deployment descriptor.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.14 $ $Date: 2001/09/20 23:34:42 $
  + * @version $Revision: 1.15 $ $Date: 2002/02/16 01:07:11 $
    */
   
   public final class InvokerServlet
  @@ -384,10 +384,14 @@
           sb.append("/");
           sb.append(servletClass);
           wrequest.setServletPath(sb.toString());
  -        if ((pathInfo == null) || (pathInfo.length() < 1))
  +        if ((pathInfo == null) || (pathInfo.length() < 1)) {
               wrequest.setPathInfo(null);
  -        else
  +            wrequest.setPathTranslated(null);
  +        } else {
               wrequest.setPathInfo(pathInfo);
  +            wrequest.setPathTranslated
  +                (getServletContext().getRealPath(pathInfo));
  +        }
   
           // Allocate a servlet instance to perform this request
           Servlet instance = null;
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to