Dear all i am not getting the thing that has been wriiten in Head Fiirst Servlet Jsp page 137 that the sendRedirect() method through an IllegalStateException if you try to invoke it after "the response has allraedy been comited" Here what is mean of response comited kindly write a bit of code...
What they are saying is if after sending a response to the client, you then call sendredirect the exception will be thrown. Think about it, you can't ask the browser to make another request after you have already responded to the same request. I am sure the experts here can add more. However, in the meantime you can google or search the forum for sendRedirect.
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
When you start writing information to the client, it first gets 'buffered', which means the information is held in memory so that large chunks of data can be sent rather than lots of small chunks. This is more efficient.
It also means that you can start building a response and then change your mind.
There is an important thing about sendRedirect, where the information is sent in the HTTP header, which is the first bit of data sent to the client. Therefore the buffer needs to be cleared before a sendRedirect is sent to the client, otherwise it will not work.
The buffer is finite in size, 8kb by default. If you put too much information in, the buffer will start sending data to the client. At this stage, it is too late to clear the buffer, and the response is considered 'committed', that is you are committed to sending the original response and cannot now send another response, such as a sendRedirect.
Hopefully this clears things up. The response gets buffered, the buffer gets committed (sent), and the sendRedirect cannot clear the buffer and fails.