When will a servlet engine send the HTTP response header? Is it immediately after getWriter/getOutputStream is called, or is it just before any call to write()?

John Mitchell

This is an implementation specific detail of the servlet engines. I.e., it depends. Of course, at the very best, once you've flushed content to the client, there's no way back. :-)

In the Java Servlet Specification v2.2, section 6.1, support has been added which gives the servlet developer a lot more information and at least some hope of portably being able to control the buffering.