Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 47326 invoked from network); 9 Jul 2003 18:12:35 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 9 Jul 2003 18:12:35 -0000 Received: (qmail 29194 invoked by uid 97); 9 Jul 2003 18:15:05 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@nagoya.betaversion.org Received: (qmail 29187 invoked from network); 9 Jul 2003 18:15:05 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 9 Jul 2003 18:15:05 -0000 Received: (qmail 46536 invoked by uid 500); 9 Jul 2003 18:12:27 -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 46522 invoked from network); 9 Jul 2003 18:12:26 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 9 Jul 2003 18:12:26 -0000 Received: (qmail 29155 invoked by uid 50); 9 Jul 2003 18:14:56 -0000 Date: 9 Jul 2003 18:14:56 -0000 Message-ID: <20030709181456.29154.qmail@nagoya.betaversion.org> From: bugzilla@apache.org To: tomcat-dev@jakarta.apache.org Cc: Subject: DO NOT REPLY [Bug 21440] New: - whose target performs a 'forward' does not behave as expected X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21440 whose target performs a 'forward' does not behave as expected Summary: whose target performs a 'forward' does not behave as expected Product: Tomcat 4 Version: 4.1.24 Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Normal Priority: Other Component: Jasper 2 AssignedTo: tomcat-dev@jakarta.apache.org ReportedBy: pierre.delisle@sun.com CC: jan.luehe@sun.com It appears that tomcat does not behave properly when a JSP page invokes a whose target performs a 'forward'. Details below. --- SETUP Foo.html FOO ForwardServlet.java: /** * A servlet that performs a RequestDispatcher.forward() * to "Foo.html". */ package tsc.servlet; import java.io.IOException; import javax.servlet.*; public class ForwardServlet extends GenericServlet { public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { ServletContext context = getServletContext(); String path="/Foo.html"; RequestDispatcher rd = context.getRequestDispatcher(path); rd.forward(req, res); } } Forward.jsp: --- TestCase 1 With the following example: TestCase1.jsp ------------- ***1*** ***2*** <% System.out.println("TestCase1.jsp"); %> The expected result is that only "FOO" will be displayed on the resulting page, and "TestCase1.jsp" will be displayed on the console. Here is why: In JSP 5.4, it is stated that: "Inclusion is into the current value of out." ... "An included page only has access to the JspWriter object and it cannot set headers. This precludes invoking methods like setCookie. Attempts to invoke these methods will be ignored. The constraint is equivalent to the one imposed on the include method of the RequestDispatcher class." Although it would not hurt the spec to be a little more specific, the assumption here is that the RequestDispatcher.include() has to be called with a response object whose 'writer' is shared with the "including" page. Given that the target of the 'include' is a servlet that performs a RequestDispather.forward(), the following will happen (as per SRV 8.4): - output data in the response buffer is cleared - response content is sent and committed, and closed. > From the viewpoint of our original TestCase1.jsp page, this therefore means that: - "***1***" is added to the response output - "***1***" gets cleared from the response output - FOO is added to the response output - the response output is closed - '***2***' does not get added to the response output because it has already been closed - The 'System.out()' statement gets executed. If this example is run with Tomcat 4.1.24, the output is: ***1*** FOO and "TestCase1.jsp" is NOT displayed on the console. Not as expected. --- Moreover, with the following example: TestCase2.jsp ------------- ***1*** ***2*** <% System.out.println("TestCase2-a.jsp"); %> ***3*** <% System.out.println("TestCase2-b.jsp"); %> The expected result is that "TestCase2-a.jsp" will be displayed on the console and that an IllegalStateException will be thrown. [Exception should be thrown because the response has already been committed with the first forward (via the first include), and a forward cannot be done (via the second include) when a response has already been committed.] If this example is run with Tomcat 4.1.24, the output is: ***1*** FOO nothing is displayed on the console, and no exception is thrown. --- Also, in the above two test cases, if ForwardServlet is replaced by Forward.jsp as the target of the 's: TestCase1 works as expected TestCase2 FOO "TestCase2-a.jsp" is displayed on the console IllegalStateException is not thrown --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org