Uploaded image for project: 'JBoss Portal'
  1. JBoss Portal
  2. JBPORTAL-2242

pass Content-Disposition property to client



      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 )
      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
      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:

        Gliffy Diagrams




              • Assignee:
                theute Thomas Heute
                croft David Wallace Croft
              • Votes:
                0 Vote for this issue
                3 Start watching this issue


                • Created: