]
Thomas Heute resolved JBPORTAL-2242.
------------------------------------
Fix Version/s: 2.7.1 Final
Resolution: Done
Assignee: Thomas Heute
Should be fixed
pass Content-Disposition property to client
-------------------------------------------
Key: JBPORTAL-2242
URL:
https://jira.jboss.org/jira/browse/JBPORTAL-2242
Project: JBoss Portal
Issue Type: Feature Request
Security Level: Public(Everyone can see)
Components: Portal Portlet
Affects Versions: 2.7.0 Final
Reporter: David Croft
Assignee: Thomas Heute
Priority: Minor
Fix For: 2.7.1 Final
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:
@Override
public void serveResource (
final ResourceRequest resourceRequest,
final ResourceResponse resourceResponse )
throws IOException
////////////////////////////////////////////////////////////////////////
{
resourceResponse.setContentType ( "application/text" );
resourceResponse.setProperty (
"Content-Disposition", "attachment; filename=test.txt" );
[...]
resourceResponse.getPortletOutputStream ( ).write ( bytes );
}
Using telnet to capture the response, here are the HTTP headers returned:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200
807181417)/JBossWeb-2.0
Set-Cookie: JSESSIONID=72772F58EB72E50E06EBACFA009F9F95; Path=/
Content-Type: application/text
Content-Length: 1090
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:
http://www.javareference.com/jrexamples/viewexample.jsp?id=103
http://www.ietf.org/rfc/rfc2183.txt
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: