tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrey Akselrod" <aaksel...@runtime.com>
Subject IllegalStateException - tomcat 4
Date Thu, 15 Feb 2001 16:35:22 GMT
Hello,

I have searched archives and have seen similar discussions, but could not
really find an answer.
I am developing a software on top of Servlet API 2.3 so I do need to use
Tomcat at least for now. I tried to create a very simplified test case. I
was able to reproduce a part of the problem so far, so that I can move
forward.
I am getting the following exception:

java.lang.IllegalStateException: Cannot forward after response has been
committed
	at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatch
er.java:245)
	at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher
.java:236)
	at
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java
:386)
	at
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:144)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.
java:573)
	at
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatch
er.java:483)
	at
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher
.java:388)
	at
_0002ffirst_0002ejspfirst_jsp_28._jspService(_0002ffirst_0002ejspfirst_jsp_2
8.java:57)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:184)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:328)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:407)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:215)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:251)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:196)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
	at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2041)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161
)
	at org.apache.catalina.valves.ValveBase.invokeNext(ValveBase.java:242)
	at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:414)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:975)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:159)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
	at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
818)
	at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:897)
	at java.lang.Thread.run(Thread.java:484)


This problem happens when I try to include a servlet from a jsp page:
<H1>First JSP</H1>
<%
out.flush();
//RequestDispatcher d = request.getRequestDispatcher("/second.jsp");
RequestDispatcher d =
request.getRequestDispatcher("/servlet/includetest.secondservlet");
d.include(request, response);
%>

The servlet itself can be empty or can simply print out something with:
resp.getWriter().println("look ma, i am here.");

If I try to include /second.jsp - it works without the exception. It fails
only for the servlet.
By "failing" I mean that it generates an exception in the log the first time
I try to execute my jsp file after Tomcat was restarted. After that it just
works fine.
It also works if I remove "flush()" - but then the output of the servlet
comes before the output of jsp file.
Another interesting thing: the test case works in ServletExcec.

I read the spec - it says that there are limitations with "forward", but
"include" should be just fine.
Another question is if you take a look at the stack - it calls "include" and
after that it calls "forward" where it fails - any idea why?

Thank you,

Andrey Akselrod, Senior Software Architect
aakselrod@runtime.com
======================================================================
RUNTIME TECHNOLOGIES                                  www.runtime.com
515 Greenwich Street, 2nd Floor                   T.212.462.2800.X.104
New York, New York 10013                                F.212.462.1074
======================================================================



Mime
View raw message