• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

reponse already been committed

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

java.lang.IllegalStateException: Response has already been committed
at org.apache.tomcat.core.HttpServletResponseFacade.sendError(HttpServletResponseFacade.java:157)
at org.apache.jasper.runtime.JspServlet.unknownException(JspServlet.java:299)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java, Compiled Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java, Compiled Code)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java, Compiled Code)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java, Compiled Code)
at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java, Compiled Code)
at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java, Compiled Code)
at java.lang.Thread.run(Thread.java, Compiled Code)

what does this error mean.
can any one help
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I ran into a problem like that using JDBC. I had to add these two lines(not directly following each other).
con.setAutoCommit( false );
con.commit();
where con is:
con = DriverManager.getConnection (URL,username,password);
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Randall Twede:
I ran into a problem like that using JDBC


Hmmmm. Would you expect an exception in an object called "HttpServletResponseFacade" because of a JDBC problem? In fact, there is no trace of JDBC in the entire stack trace.
Whenever you call a method that needs to set response header fields, the HttpResponse object will generate an IllegalStateException if the response has already been committed. "Committed" means that the first chunk of the response -- including the header -- has already been sent off to the client because the buffer was full. Obviously, once you've sent off the header you can't modify it any more
To fix this, make sure you do all your error checking, setting of content type etc. etc. before starting to produce content in earnest. In practice this means: move all this stuff to the very start of your JSP.
HTH
- Peter

[This message has been edited by Peter den Haan (edited February 16, 2001).]
 
Randall Twede
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Peter,
I shouldnt stay up so late.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Randall Twede:
Peter,
I shouldnt stay up so late.


Hi,
I got this error when I wrote the following code in a html form:
<jsp:useBean id="a_id" class="a_Bean_class" scope="request">
<jsp:setProperty name="formhandler" property="*"/>
</jsp:useBean>
I fixed it by defining a corresponding getter/setter for each property within the bean. There is a very good article on this topic in javaworld March 2000. Article is "advanced form processing using JSP"
Good luck.
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"FrankInTheHouse",
Well I'm Frank, and I'm at the Ranch ...
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have also seen the error message
Included servlet error: 500
java.lang.IllegalStateException: Response has already been committed
when I have been using jsp:include and have specified a page attribute (page=) that is not present (or my path is incorrectly specified for the page).
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is in the response being sent to the browser
see the first few lines of the stack trace:
java.lang.IllegalStateException: Response has already been committed
at org.apache.tomcat.core.HttpServletResponseFacade.sendError HttpServletResponseFacade.java:157)
at org.apache.jasper.runtime.JspServlet.unknownException(JspServlet.java:299)

The jsp is being evaluated and some output is being written to the (buffered) output stream. It is safe to change the page that is returned UP TO the point when the buffer is full and something actually gets sent to the client. At this point the HTTP header has been written and the reponse is considered 'committed'.<br>Going back to the stack trace, an unknown exception is being thrown, the app server tries to redirect to the error page (the call to 'sendError') but fails since it is no longer possible to change the page tyhat will be returned.
I'd have to mess around with it a bit and it would be implementation dependant, but using the JSP directives to increase the buffer and remove auto-flushing might help.
Note that this can also occur when RequestDispatcher.forward() is used. (ie forward to a new page that throws an exception,. but the page has been 'locked in' so it is not possible to redirect to the error page)
[This message has been edited by David O'Meara (edited March 06, 2001).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic