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 org.apache.catalina.core.ApplicationDispatcher.forward (ApplicationDispatcher.java:356) ...
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.
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.
CC'ing the taglibs-dev address to all Standard bugs.
Created attachment 11554 [details] JSP and Servlet test files
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.