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 ]
|