Return-Path: Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 59572 invoked from network); 15 Feb 2001 20:45:35 -0000 Received: from ns.sohonet.com (HELO null.runtime.com) (63.87.238.3) by h31.sny.collab.net with SMTP; 15 Feb 2001 20:45:35 -0000 Received: from [208.215.135.74] (HELO whitestar) by null.runtime.com (CommuniGate Pro SMTP 3.4b9) with SMTP id 837462 for tomcat-user@jakarta.apache.org; Thu, 15 Feb 2001 15:45:13 -0500 From: "Andrey Akselrod" To: Subject: RE: IllegalStateException - tomcat 4 Date: Thu, 15 Feb 2001 15:44:24 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: <3A8C2E2B.BCDE35A5@eng.sun.com> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Craig, Michael, thank you for your help! Craig, your last email explained everything - thank you. I am a lot less stressed now :) I have a few questions though. Instead of mapping each servlet I just removed /servlet/* invoker mapping. It worked after that. Is it safe to do so? What does the invoker do? I took a look at the source code - and realized that you wrote it! Thanks for taking your time to explain it all... Anyway, why do you forward instead of include in there? How come Tomcat works without this association (/servlet/*)? Thank you again, -a > -----Original Message----- > From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com] > Sent: Thursday, February 15, 2001 2:30 PM > To: tomcat-user@jakarta.apache.org > Subject: Re: IllegalStateException - tomcat 4 > > > The reason you are getting the exeption is that the invoker > servlet (the one mapped to > "/servlet/*" does a RequestDispatcher.forward() to call the > actual servlet class. > Thus, you are getting the error because you did the flush() in > the JSP page before > calling. NOTE: The existence of an invoker servlet is a Tomcat > feature, and is not > part of the spec, so there are no rules about how they work. > > To avoid this problem, you should set up a > entry in your web.xml file > so that you can do a request dispatcher directly to your servlet > itself. For example, > if you have the following entries in web.xml: > > > MyServlet > includetest.secondservlet > > > > MyServlet > /include-test > > > Then you can call your dispatcher like this: > > <% > out.flush(); > RequestDispatcher rd = > request.getRequestDispatcher("/include-test"); > rd.include(request, response); > %> > > or, even simpler: > > > > Craig McClanahan > > PS: Removing the flush() in your calling page would also make > the original example > work correctly :-). > > > > > Andrey Akselrod wrote: > > > 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(Applicati > onDispatch > > er.java:245) > > at > > > org.apache.catalina.core.ApplicationDispatcher.forward(Application > Dispatcher > > .java:236) > > at > > > org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerSe > rvlet.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(ApplicationD > ispatcher. > > java:573) > > at > > > org.apache.catalina.core.ApplicationDispatcher.doInclude(Applicati > onDispatch > > er.java:483) > > at > > > org.apache.catalina.core.ApplicationDispatcher.include(Application > Dispatcher > > .java:388) > > at > > > _0002ffirst_0002ejspfirst_jsp_28._jspService(_0002ffirst_0002ejspf > irst_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(Jsp > Servlet.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(Applicati > onFilterCh > > ain.java:215) > > at > > > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapp > erValve.ja > > va:251) > > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977) > > at > > > org.apache.catalina.core.StandardContextValve.invoke(StandardConte > xtValve.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(StandardHostValv > e.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(StandardEngine > Valve.java > > :159) > > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977) > > at > > > org.apache.catalina.connector.http.HttpProcessor.process(HttpProce > ssor.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: > >

First JSP

> > <% > > 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 > > ====================================================================== > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > > For additional commands, email: tomcat-user-help@jakarta.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > For additional commands, email: tomcat-user-help@jakarta.apache.org > >