Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2007

Tip: Looking for answers? Try searching our database.

ServletResponse headers

Thread view: 
dave - 07 Aug 2007 21:29 GMT
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?
Arne Vajhøj - 07 Aug 2007 22:04 GMT
> 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
dave - 07 Aug 2007 23:18 GMT
On Aug 7, 5:04 pm, Arne Vajh?j <a...@vajhoej.dk> wrote:

> Yes. No.
>
[quoted text clipped - 3 lines]
>
> 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?
Wojtek - 07 Aug 2007 23:30 GMT
dave wrote :

>> Yes. No.
>>
[quoted text clipped - 12 lines]
> 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...

Signature

Wojtek :-)

Arne Vajhøj - 08 Aug 2007 01:18 GMT
>> Yes. No.
>>
[quoted text clipped - 12 lines]
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.