velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sid...@apache.org
Subject cvs commit: jakarta-velocity-tools/view/src/java/org/apache/velocity/tools/view/servlet VelocityViewServlet.java
Date Tue, 07 May 2002 10:23:34 GMT
sidler      02/05/07 03:23:33

  Modified:    view/src/java/org/apache/velocity/tools/view/servlet
                        VelocityViewServlet.java
  Log:
  Modified VelocityViewServlet.handleRequest() method so that it now
  can handle being called from RequestDispatcher.include()
  (Thanks to Jeff Schnitzer for the patch)
  
  Revision  Changes    Path
  1.5       +12 -2     jakarta-velocity-tools/view/src/java/org/apache/velocity/tools/view/servlet/VelocityViewServlet.java
  
  Index: VelocityViewServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity-tools/view/src/java/org/apache/velocity/tools/view/servlet/VelocityViewServlet.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- VelocityViewServlet.java	4 Apr 2002 13:05:56 -0000	1.4
  +++ VelocityViewServlet.java	7 May 2002 10:23:33 -0000	1.5
  @@ -116,7 +116,7 @@
    * @author <a href="mailto:sidler@teamup.com">Gabe Sidler</a>
    * @author  <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
    *
  - * @version $Id: VelocityViewServlet.java,v 1.4 2002/04/04 13:05:56 sidler Exp $
  + * @version $Id: VelocityViewServlet.java,v 1.5 2002/05/07 10:23:33 sidler Exp $
    */
   
   public class VelocityViewServlet extends VelocityServlet
  @@ -269,7 +269,17 @@
                                        Context ctx )
           throws Exception
       {
  -        return getTemplate(request.getServletPath() );
  +        // If we get here from RequestDispatcher.include(), getServletPath()
  +        // will return the original (wrong) URI requested.  The following special
  +        // attribute holds the correct path.  See section 8.3 of the Servlet
  +        // 2.3 specification.
  +        String path = (String)request.getAttribute("javax.servlet.include.servlet_path");
  +        if (path == null)
  +        {
  +            path = request.getServletPath();
  +        }
  +
  +        return getTemplate(path);
       }
   
   
  
  
  

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


Mime
View raw message