Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 86096 invoked from network); 31 May 2003 01:18:36 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 31 May 2003 01:18:36 -0000 Received: (qmail 15103 invoked by uid 97); 31 May 2003 01:20:55 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@nagoya.betaversion.org Received: (qmail 15096 invoked from network); 31 May 2003 01:20:55 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 31 May 2003 01:20:55 -0000 Received: (qmail 85233 invoked by uid 500); 31 May 2003 01:18:23 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 85222 invoked from network); 31 May 2003 01:18:23 -0000 Received: from nwkea-mail-1.sun.com (192.18.42.13) by daedalus.apache.org with SMTP; 31 May 2003 01:18:23 -0000 Received: from phys-d3-ha21sca-1 ([129.145.155.163]) by nwkea-mail-1.sun.com (8.12.9/8.12.9) with ESMTP id h4V1IW4Z013196 for ; Fri, 30 May 2003 18:18:32 -0700 (PDT) Received: from Sun.COM (misto.SFBay.Sun.COM [129.145.132.207]) by ha21sca-mail1.sfbay.sun.com (iPlanet Messaging Server 5.2 HotFix 1.10 (built Jan 23 2003)) with ESMTP id <0HFQ00F0O8YWRI@ha21sca-mail1.sfbay.sun.com> for tomcat-dev@jakarta.apache.org; Fri, 30 May 2003 18:18:32 -0700 (PDT) Date: Fri, 30 May 2003 18:18:32 -0700 From: Jan Luehe Subject: [PATCH] RequestDispatcher.forward() problem with wrapped requests Sender: Jan.Luehe@Sun.COM To: tomcat-dev@jakarta.apache.org Reply-to: Jan.Luehe@Sun.COM Message-id: <3ED802E8.DB0E4DE0@Sun.COM> MIME-version: 1.0 X-Mailer: Mozilla 4.79C-CCK-MCD [en] (X11; U; SunOS 5.9 sun4u) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Accept-Language: en X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N I am fixing a bug filed by Ryan Lubke (Bugtraq 4871238). I do have a fix in place, but I would like to make sure it's appropriate. Consider the following scenario: Servlet1 acquires a RequestDispatcher and forwards the request to Servlet2. However, before forwarding the request, it wraps the request inside an HttpServletRequestWrapper. The problem is that Servlet2 never gets invoked. If you look at ApplicationDispatcher.processRequest(), you'll see that the target servlet (Servlet2) is invoked only if the DISPATCHER_TYPE_ATTR attribute has been set on the request. Since we're passing to the RequestDispatcher an instance of HttpServletRequestWrapper, ApplicationDispatcher.wrapRequest() will replace the original wrapped request with an instance of ApplicationHttpRequest, which is constructed from the original wrapped request. ApplicationDispatcher.wrapRequest() essentially does this: HttpServletRequest wrapped = wrapper.getRequest(); wrapper.setRequest(new ApplicationHttpRequest(wrapped)); The problem is that the DISPATCHER_TYPE_ATTR and DISPATCHER_REQUEST_PATH_ATTR attributes on the original wrapped request do not get propagated onto the ApplicationHttpRequest, and therefore, getting these attributes from the HttpServletRequestWrapper, which simply delegates to the wrapped ApplicationHttpRequest, returns null, causing the target servlet to not get invoked. My suggested fix is to consider these attributes when constructing an ApplicationHttpRequest from an HttpServletRequest, like this (in ApplicationHttpRequest.setRequest()): Index: ApplicationHttpRequest.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationHttpRequest.java,v retrieving revision 1.8 diff -u -r1.8 ApplicationHttpRequest.java --- ApplicationHttpRequest.java 26 May 2003 12:02:31 -0000 1.8 +++ ApplicationHttpRequest.java 31 May 2003 01:05:08 -0000 @@ -524,6 +524,10 @@ super.setRequest(request); // Initialize the attributes for this request + dispatcherType = request.getAttribute(Globals.DISPATCHER_TYPE_ATTR); + requestDispatcherPath + = request.getAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR); + /* synchronized (attributes) { attributes.clear(); This fixes the problem. Please let me know if you agree, and I'll commit. Thanks, Jan --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org