I would like JBoss Portal to pass the Content-Disposition HTTP header to the browser client. I need to be able to have users click a button in a portlet to download a dynamically generated file to their desktop. I am able to do this using the Resource Serving feature of JSR-286 and by setting the "Content-Type" HTTP header to "application/text" using the setContentType() method.
The only snag is that the filename cannot be set to a reasonable default set such as "file.txt". Normally the default filename can be set using the "Content-Disposition" HTTP header. The JSR-286 specification provides a method setProperty() on class ResourceResponse which can be used to set an HTTP header.
Here is the code I attempted:
public void serveResource (
final ResourceRequest resourceRequest,
final ResourceResponse resourceResponse )
Using telnet to capture the response, here are the HTTP headers returned:
HTTP/1.1 200 OK
X-Powered-By: Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200
Set-Cookie: JSESSIONID=72772F58EB72E50E06EBACFA009F9F95; Path=/
Date: Mon, 17 Nov 2008 17:41:58 GMT
As you can see, the Content-Type was set but Content-Disposition was not.
It is my understanding that it is optional for the portal to pass the properties along. Quoting from the JSR-286 specification:
"The portlet should note that headers set on the response are not guaranteed to be transported to the client as the portal application may restrict headers due to security reasons, or they may conflict with other headers set by other portlets on the page."
"Note that it is not guaranteed that headers, like cookies, will be transmitted all the way back to the client."
Even though it is optional, I would like for JBoss Portal to pass along the Content-Disposition property to the browser client so that I can set the download filename when using the JSR-286 resource serving feature.
Here is more on the Content-Disposition HTTP header and its use: