WebSphere Portal Server - PortletResponse addHeader vs. setHeader

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Portal Server > September 2006 > PortletResponse addHeader vs. setHeader





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author PortletResponse addHeader vs. setHeader
Brian J. Sayatovic

2006-09-25, 7:38 pm

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.


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com