Originally posted by Jothi Shankar Kumar Sankararaj:
"The servlet container does not write the headers before committing the response, because in HTTP the headers must be sent before the response body."
Jothi,
I don't understand the statement. What I know is that if we try to write headers after the response has been commited we get an IllegalStateException. There is no way that the Container won't write the headers before (if you didn't specify any, it will write the defaults). What I think happens is that the Container will send the headers just before it sends what we wrote to the outputStream when commiting the response (e.g., flushes the buffer for the first time if there is a buffer, or if there is no buffer when the first char is sent).