• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ServletResponse.isCommitted()

 
Tom Adams
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Several methods etc. throw a IllegalStateException if a response is already committed....
What causes the response to be committed? I know it happens once the response header has been sent to the browser but at what point does this occur?
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to Servlet API, method flushBuffer() in class ServletResponse will commit the response and force any content in the buffer to be written to the client..
daniel
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3776
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tom Adams:
Several methods etc. throw a IllegalStateException if a response is already committed....
What causes the response to be committed? I know it happens once the response header has been sent to the browser but at what point does this occur?

In practice, it might happen any time during the processing of the request. The container regularly flushes the buffer while the servlet is writing to the response. Since the headers are the first part of the response, they are the first ones to be flushed out and the response is committed.
Then, of course, there are methods that force the container to flush the buffer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic