Forums Register Login

Response Headers

+Pie Number of slices to send: Send
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();
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
I think you can set several headers at one time, don't need to set it one by one.
+Pie Number of slices to send: Send
Do all headers have to be sent before the response body is sent?
+Pie Number of slices to send: Send
 

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
Whip out those weird instruments of science and probe away! I think it's a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 701 times.
Similar Threads
Midlet Download/Installation Status Codes via servlet/jsp
doubt in flushBuffer
logout problem
response.isCommitted()???
Hard problem with tomcat 4.1 and jwsdp-1.3
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:09:51.