You don't need to forward back to the original servlet. Each call is done as a stack, so when the JSP returns, control comes back to the Create servlet. When the Create servlet returns, control comes back to the Home servlet.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 9:27 AM To: [EMAIL PROTECTED] Subject: RE: How can I resolve this "IllegalStateException: Response has a lrea dy been committed" problem? Yep that's right. Only one forward getting done per request. The main controller servlet (e.g. "Home") forwards to another more specific controller servlet (e.g. "Create"), which then forwards to a JSP. Then later, that servlet forwards back (?? Maybe this isn't wise?) to the main controller servlet. A whole lot of forwarding going on. -----Original Message----- From: Ryan Daigle [mailto:[EMAIL PROTECTED]] Sent: 08 March 2002 13:56 To: 'Tomcat Users List' Subject: RE: How can I resolve this "IllegalStateException: Response has a lrea dy been committed" problem? My impression of this situation was that at runtime there was only one request forward happening. The Home servlet may have more than one forward call, but at runtime only one gets executed (per request), right? So within each servlet only one forward happens, but a string of servlets has more than one forward total. Is this correct? Ryan Daigle Java Developer Health Decisions, Inc. 1512 E. Franklin St, Suite 200 Chapel Hill, NC 27514 (919) 967-2399 ext: 251 [EMAIL PROTECTED] http://www.healthdec.com -----Original Message----- From: Wagoner, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 8:58 AM To: 'Tomcat Users List' Subject: RE: How can I resolve this "IllegalStateException: Response has a lrea dy been committed" problem? Is it possible to change the Create servlet to a simple class that accepts the request as a parameter? Since it does not manipulate the response object, there is no need to pass it. Also, you can then call Create using a regular method invocation, rather than using forward. It may require some work, but you could eliminate the "double forward" issue. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 8:45 AM To: [EMAIL PROTECTED] Subject: RE: How can I resolve this "IllegalStateException: Response has a lrea dy been committed" problem? The exception seems to be occurring because the Home servlet forwards more than once (to different locations) - first to home.jsp, then later to the Create servlet. It is definitely the fact that it is forwarding to more than one place, that is causing the problem. I know this because if I call the Login servlet and fail the login authorization - this servlet consequently forwards to login.jsp more than once (first - to display the fresh login page, and second - to prompt user to try again). This however does not give me an exception. Given that my Home servlet is like the "central" servlet, it needs to be capable of forwarding to a variety of places, depending on the activity selected by the user. Ryan - I have looked at create.jsp and, as far as my little mind can see, it does not play with the response object at all. All it does is get a few session attributes and fit them into the page using <%= blablabla %>. Could that be a problem? This problem is not isolated to the "Create" example. There are other activities the user can choose which all follow exactly the same forwarding mechanism (except to different servlets), and these give exactly the same exception. Lindsay -----Original Message----- From: Ryan Daigle [mailto:[EMAIL PROTECTED]] Sent: 08 March 2002 13:25 To: 'Tomcat Users List' Subject: RE: How can I resolve this "IllegalStateException: Response has a lrea dy been committed" problem? Are you sure there isn't something in create.jsp that is trying to manipulate the response? I have found that trying to do a "<jsp:include...>" after manipulating the session can cause this exception. Is this a possibility? Perhaps you could send the relevant source of create.jsp and the Create servlet? -Ryan -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 8:26 AM To: [EMAIL PROTECTED] Subject: RE: How can I resolve this "IllegalStateException: Response has a lrea dy been committed" problem? OK here's the sequence of events: [ Note: all forwarding done using RequestDispatcher.forward(req,res) ] 1. User begins by clicking link to Login servlet 2. Login servlet forwards to login.jsp 3. Login.jsp submits request to Login servlet 4. Servlet authorizes user and forwards to Home servlet 5. Home servlet forwards to home.jsp NO EXCEPTIONS YET - EVERYTHING IS OK! 6. User then chooses an action (e.g. create new agent, in my example) from home.jsp and submits request to Home servlet 7. Home servlet processes request and forwards to appropriate servlet (called Create in my example) 8. Create servlet does some stuff and forwards to create.jsp BANG! I GET THIS EXCEPTION (I have included some buildup to this exception): Now in Home servlet - processing request... 2002-03-08 13:19:08 - DecodeInterceptor: Charset from session ISO-8859-1 Now in Create servlet - processing request... Getting list of available types seems to have went OK 2002-03-08 13:19:09 - Ctx(/AgentGenerator) : IllegalStateException in R( /AgentGenerator + /create.jsp + null) - java.la ng.IllegalStateException: Cannot forward because the response has already been committed at org.apache.tomcat.facade.RequestDispatcherImpl.doForward(Unknown Source) at org.apache.tomcat.facade.RequestDispatcherImpl.forward(Unknown Source) at zeus.generator.web.controllers.Home.goToAddress(Home.java:157) at zeus.generator.web.controllers.Home.processRequest(Home.java:120) at zeus.generator.web.controllers.Home.doGet(Home.java:131) at javax.servlet.http.HttpServlet.service(HttpServlet.java) at javax.servlet.http.HttpServlet.service(HttpServlet.java) at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source) at org.apache.tomcat.core.Handler.invoke(Unknown Source) at org.apache.tomcat.core.Handler.service(Unknown Source) at org.apache.tomcat.facade.ServletHandler.service(Unknown Source) at org.apache.tomcat.core.ContextManager.internalService(Unknown Source) at org.apache.tomcat.core.ContextManager.service(Unknown Source) at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Unknown Source) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown Source) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown Source) at java.lang.Thread.run(Thread.java:484) But the page is being displayed OK, and the application continues to function properly. I'd just like to get rid of this exception somehow. Maybe the way I am forwarding so much is not the best way to do things, but it is working. What alternatives are there? Oh, I get the same sort of messages when I substitute requestDispatcher.forward() with response.sendRedirect(). Many thanks if anyone can assist, Cheers Lindsay -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]> -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]> -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]> -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]> -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]> -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>