Bug 20940 - Cant't import servlet which redirects to another page
Summary: Cant't import servlet which redirects to another page
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: 1.0.2
Hardware: PC other
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on: 21440
  Show dependency tree
Reported: 2003-06-20 07:48 UTC by Thomas Mathis
Modified: 2009-08-17 02:03 UTC (History)
0 users

JSP and Servlet test files (713 bytes, application/octet-stream)
2004-05-14 20:50 UTC, Justyna Horwat

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Mathis 2003-06-20 07:48:27 UTC
I want to import a page from a servlet which redirects to a JSP page.
<c:import url="/servlet/MyRedirectServlet" />

If I import the same url from another server 
<c:import url="http://anyhost.com/webappname/servlet/MyRedirectServlet" />
it works fine.

Following error appears INSIDE the jsp-page: 

java.lang.IllegalStateException: Cannot forward after response has been 
committed at org.apache.catalina.core.ApplicationDispatcher.doForward
(ApplicationDispatcher.java:368) at 
Comment 1 Thomas Mathis 2003-06-20 08:05:58 UTC
Sorry: Of course I mean FORWARD instead of REDIRECT (as you can see in the java 
error stacktrace): 

I want to import a page from a servlet which forwards to a JSP page.
<c:import url="/servlet/MyForwardServlet" />

If I import the same url from another server 
<c:import url="http://anyhost.com/webappname/servlet/MyForwardServlet" />
it works fine.
Comment 2 Pierre Delisle 2003-07-12 13:49:51 UTC
This bug report triggered some investigation on the behavior of 
<jsp:include> and RequestDispatcher.forward(). This eventually led
to filing bug report 21440.

Since the behavior of <c:import> is defined in function of <jsp:include>,
I'll wait to see how this bug report is handled before addressing this one.
Comment 3 Felipe Leme 2004-05-12 00:26:58 UTC
CC'ing the taglibs-dev address to all Standard bugs. 
Comment 4 Justyna Horwat 2004-05-14 20:50:13 UTC
Created attachment 11554 [details]
JSP and Servlet test files
Comment 5 Justyna Horwat 2004-05-14 20:54:37 UTC
Followed up with Jan Luehe from the Tomcat community on the status of this bug. He did commit a fix 
to org.apache.jasper.runtime.ServletResponseWrapperInclude (on 2003/07/11). This fix addresses the 
scenario reported in this report, Bugzilla 20940. 

However, this is only a partial fix for Buzilla 21440. (TestCase1 in Bugzilla 21440 is fixed but TestCase2 
is still under investigation pending specification clarification).

I verified in Tomcat 5.0.19 that the c:import when importing a jsp or a servlet that forwards to another 
page as described in this bug report works successfully. Attached are the TestCases that I used 
including one for forward from a JSP and one from a Servlet.