Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 61759 invoked from network); 8 Mar 2002 15:41:20 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 8 Mar 2002 15:41:20 -0000 Received: (qmail 21663 invoked by uid 97); 8 Mar 2002 15:40:32 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@jakarta.apache.org Received: (qmail 21626 invoked by uid 97); 8 Mar 2002 15:40:32 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 21576 invoked from network); 8 Mar 2002 15:40:31 -0000 Message-ID: From: lindsay.hamoudi@bt.com To: tomcat-user@jakarta.apache.org Subject: RE: How can I resolve this "IllegalStateException: Response has a lrea dy been committed" problem? Date: Fri, 8 Mar 2002 15:39:12 -0000 X-Mailer: Internet Mail Service (5.5.2654.89) MIME-version: 1.0 Content-type: text/plain; charset="ISO-8859-1" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Much appreciated. I am a bit of a newbie with servlets and JSP. I thought I was following the MVC architecture (controller servlets, view JSPs, model components and session beans, etc) but after looking at some Struts docs - it seems there is a whole lot more to this. Thanks for the info, and I shall now retreat to a quiet little corner and get stuck into Struts. (Actually no - it's Friday - I'll do that on Monday!) Cheers. -----Original Message----- From: jeff.guttadauro@abbott.com [mailto:jeff.guttadauro@abbott.com] Sent: 08 March 2002 15:04 To: Tomcat Users List Subject: RE: How can I resolve this "IllegalStateException: Response has a lrea dy been committed" problem? If you are getting any pages back from the server, then you are using the response object! You may not be manipulating it with an explicit reference to it, but, when you have HTML or do an <% out.println("STUFF") %> or output a JSP expression like <%= something %> in your JSP pages, you are using the response object. And the deal is you can't forward if you've already started putting stuff in the response. What you should probably look into, and what some people are hinting at here, is using some sort of controller servlet that gets the request and then CALLS (not forwards to) the appropriate "handler" or "action" class. You can pass the request object along to your "handler" class so that you can get stuff from it or its session. Then, when your handler method is finished, you controller picks up immediately following its call to your handler. This allows you to have one very general controller servlet which can route the requests to more specialized handlers or actions depending on some parameter (command, action name) and can then handle forwarding to the appropriate new page. You might want to take a look at the Struts framework, which does this for you. Hope this helps. -Jeff lindsay.hamou di@bt.com To: tomcat-user@jakarta.apache.org cc: 03/08/02 Subject: RE: How can I resolve this "IllegalStateException: Response 08:43 AM has a lrea dy been committed" problem? Please respond to "Tomcat Users List" Don't think JSP is failing. It's quite a simple JSP and has been looked at exhaustively! Yes, I am setting session attributes in Create servlet, for use by create.jsp. I am only using the session object and the request throughout my application. The only time I ever knew I was using the response object was when I used response.sendRedirect(), but I don't use this anymore. I use the RequestDispatcher. There are no or tags being used anywhere, and my servlets do not contribute anything to the response (apart from forwarding it around). Mark - your words of wisdom interest me. I thought that... when I invoke requestDispatcher.forward(), then control never returns (to the line following this invocation). So how do I go about "returning" to the Home servlet from the "Create" servlet. Surely I need to "forward", because the session has changed? I have a lot to learn here I think, but I feel I'm getting closer to the holy grail - getting rid of this exception! -----Original Message----- From: Attila Szegedi [mailto:szegedia@freemail.hu] 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? I guess you JSP is failing with an uncaught exception. At that point, Tomcat would try to send a "500 Internal Server Error" response code, but it can't since a "200 OK" status code has already been sent (that is, the output committed) to the client. -- Attila Szegedi home: http://www.szegedi.org ----- Original Message ----- From: To: Sent: 2002. m�rcius 8. 14:45 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 > -- To unsubscribe: For additional commands: Troubles with the list: -- To unsubscribe: For additional commands: Troubles with the list: -- To unsubscribe: For additional commands: Troubles with the list: -- To unsubscribe: For additional commands: Troubles with the list: