PortletResponse addHeader vs. setHeader
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > WebSphere > WebSphere Portal Server > PortletResponse addHeader vs. setHeader




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    PortletResponse addHeader vs. setHeader  
Brian J. Sayatovic


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-26-06 12:38 AM

I just overcame a struggle I had in using PortletResponse.addHeader() in WPS
5.1 (JetSpeed, not JSR-168).  I took care to use the beginPage() method in
PortalPageListener, but still found a surprise.  The JavaDoc for addHeader
says:

"Adds a response header with the given name and value. This method
allows response headers to have multiple values."

There are also notes with the JavaDoc:

"We need to think about all header methods and how to solve nameclashes,
etc."

and

"Throws: java.lang.IllegalStateException - if the portlet tries to
access this function outside of the beginPage method of the
PortletPageListener or if the portlet tries to set an portal-wide header"

In practice, my header was never added to the response.  However, as soon as
I switched my code to use setHeader(), it worked.  The setHeader JavaDoc
says:

"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."

...along with the same warnings as above.  What bothers me is:

1. addHeader apparently doesn't work as described.
2. setHeader will only allow me to set a header once, whereas addHeader
presumably would not prevent that.

Does anyone have more information about this?

Regards,
Brian.







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 04:08 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register