| Author |
Response Headers
|
Ravi Singh
Ranch Hand
Joined: Aug 02, 2004
Posts: 51
|
|
Is it possible to set response headers after a response has been committed as I am under the impression that ALL response headers must be sent before the response body is sent? e.g. response.setHeader("headername", "headervalue"); response.flushBuffer(); response.setHeader("headername", "headervalue"); response.flushBuffer();
|
 |
Sundar Gopal
Greenhorn
Joined: Jun 20, 2003
Posts: 17
|
|
|
once the response is committed we can't set the header. you have used flushBuffer() which commits the response which forces 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.
|
Regards,<br />SundarGopal.<br />Scjp, Scwcd, Scbcd.
|
 |
HaoZhe Xu
Ranch Hand
Joined: Nov 03, 2003
Posts: 222
|
|
|
I think you can set several headers at one time, don't need to set it one by one.
|
[url]Olnex.net[/url]
[SCJP 1.2, SCJD, SCWCD]
|
 |
Ravi Singh
Ranch Hand
Joined: Aug 02, 2004
Posts: 51
|
|
|
Do all headers have to be sent before the response body is sent?
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12268
|
|
Do all headers have to be sent before the response body is sent?
Of course - at the TCP/IP level, the response is just a single stream of characters sent to the browser. The servlet API keeps the headers separate from the output buffer until the first buffer flush, but after that the headers have been written. Bill
|
Java Resources at www.wbrogden.com
|
 |
 |
|
|
subject: Response Headers
|
|
|