public void flushBuffer()
throws java.io.IOExceptionForces any content in the buffer to be written to the client. A call to this method automatically commits the response, meaning the status code and headers will be written.
--------------------------------------------------------------------------------
resetBuffer
public void resetBuffer()Clears the content of the underlying buffer in the response without clearing headers or status code. If the response has been committed, this method throws an IllegalStateException.
Thanks <br />Poonam Agarwal SCWCD 86%
Poonam Agarwal wrote:by commiting we mean responce headers (status code etc)are written to the brower.
that means we can call resetBuffer() before making the call , nut can not call the flushBuffer().
Regards,<br />Sourin.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Poonam I don't think calling getRequestDispatcher throws IllegalStateException if the response has already been committed. Calling forward after the response has been committed throws an IllegalStateException.
You can include any other content after the response has been committed but the included resource is not allowed to set response content type or any other response headers.
included resource is not allowed to set response content type or any other response headers.
But this will happen only if the response is in the buffer. If any content is already sent to the client, then calling resetBuffer throws an IllegalStateException...
Thanks <br />Poonam Agarwal SCWCD 86%
Poonam Agarwal wrote:
You can include any other content after the response has been committed but the included resource is not allowed to set response content type or any other response headers.
No that is absolutely wrong, you cannot write anything on the response after it's comitted. no matter whether its forward() OR include(). once response get committed , the status code and header are written.
Poonam Agarwal wrote:
But this will happen only if the response is in the buffer. If any content is already sent to the client, then calling resetBuffer throws an IllegalStateException...
please elobrate this, i did't understand what this means??
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg wrote:
Well I created a program to test this. I wrote a servlet in which I wrote some response and then included another srevlet in it. And it worked. The only thing the included servlet can't do is to set the response headers.
Regards,<br />Sourin.
Sourin K. Sen wrote:But had you flushed the response (ie, commit the response) before you included that servlet, you would have recieved an IllegalStateException.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links