If your question is "when all do we say that the response is committed?", then ...
Yes! The answer is also linked with sendError and sendRedirect too. When you send error it means that you have already given some response to that request. Same holds good for send redirect too. In these cases, control is no more with in the servlet from which you issued either of the commands.
Even when we do a flush or close on the output stream or print writer object, the response is committed. In these cases, you do still have your control in this servlet. However, setting some status in the response header like contentType et al, will not have effect on the response.
I have come thru something sayin a setStatus clears the output buffer and a sendError commits the response and both these functions result in illegalstateexception if response is already committed.
correct me if i am wrong..also sendRedirect has some dependency whether a response is committed or not.
I am not sure if the setStatus method will throw a IllegalStateException if the response is already committed as setStatus only sets the status codes in the response,but sendError will surely throw this exception.
Also if we commit response before calling sendRedirect than it will throw an IllegalStateException. Please correct me if I am wrong. Regards, Saurabh [ May 03, 2006: Message edited by: Saurabh Chaubey ]
Also if we commit response before calling sendRedirect than it will throw an IllegalStateException. Please correct me if I am wrong.
Yes you are correct.
How do we call sendRedirect() method?
Using response object. If the response object is already send to the client(response committed) then how can we call any other method using response object. You will end up getting a runtime exception(IllegalStateException).