ServletResponse headers

D

dave

Hi,

Is it possible that a SerlvetResponse will be flushed if large enough
data is set for the header section in the response? or perhaps there
is a guarantee this will not happen?
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

dave said:
Is it possible that a SerlvetResponse will be flushed if large enough
data is set for the header section in the response? or perhaps there
is a guarantee this will not happen?

Yes. No.

Check the two methods:
flushBuffer
isCommited

Arne
 
D

dave

Yes. No.

Check the two methods:
flushBuffer
isCommited

Arne

It appears that the buffer is for the response body, not the header
section, although I'm really not sure. It still wasn't clear to me
from the docs.

Suppose the response body is completely empty and someone starts
adding a large number of headers using "setHeader". Let's assume that
it is flushed, now what happens if "addHeader" is called on something
already committed?
 
W

Wojtek

dave wrote :
It appears that the buffer is for the response body, not the header
section, although I'm really not sure. It still wasn't clear to me
from the docs.

Suppose the response body is completely empty and someone starts
adding a large number of headers using "setHeader". Let's assume that
it is flushed, now what happens if "addHeader" is called on something
already committed?

I believe that addHeader simply places the information into a HashMap.

The JavaDoc for setHeader states: "Sets a response header with the
given name and value. If the header had already been set, the new value
overwrites the previous one. The containsHeader method can be used to
test for the presence of a header before setting its value."

When the resonse is ready to be sent back, then the headers are sent,
and marked as committed.

This allows you to set other response values (mime type, cookies, etc)
"out of order", as they will not be sent until the page is ready to be
sent.

Note that this is only speculation...
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

dave said:
It appears that the buffer is for the response body, not the header
section, although I'm really not sure. It still wasn't clear to me
from the docs.

Suppose the response body is completely empty and someone starts
adding a large number of headers using "setHeader". Let's assume that
it is flushed, now what happens if "addHeader" is called on something
already committed?

flushBuffer docs say:

#A call to this method automatically commits the response, meaning the
#status code and headers will be written.

I would expect a setHeader call to fail after that.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,801
Messages
2,569,658
Members
45,421
Latest member
DoreenCorn

Latest Threads

Top