You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by rob <ro...@fastmail.fm> on 2002/02/03 13:53:32 UTC
Re: populating save as... dialog for application/octet-stream content type (solved maybe)
I tried the following
request.setHeader("Content-Disposition", "attachment; filename="mypdf.pdf");
and it seemed to work, is this the correct way or is there a more
appropriate way to do this?
Thanks
----- Original Message -----
From: "rob" <ro...@fastmail.fm>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Sunday, February 03, 2002 11:01 PM
Subject: populating save as... dialog for application/octet-stream content
type
> I'm trying to 'suggest' a filename for download when I send binary output
as
> a reply.
>
> I would like the suggested filename to appear in the save as... dialog
that
> pops up when the response is sent (rather than whatever the url may be at
> the time).
>
> My servlet basically does this.
>
> setContentType("application/octet-stream");
> open a file ..
> OutputStream is = response.getOutputStream();
> loop ( read from file into buffer while not end of file )
> is.write( buffer );
> close streams input & output
>
> If there is a more appropriate list for this posting please tell me.
> Otherwise a solution would be helpful.
>
> Thanks
>
> rob
>
>
>
> --
> To unsubscribe: <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>
--
To unsubscribe: <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>
Re: populating save as... dialog for application/octet-stream
content type (solved maybe)
Posted by Gary Helmling <gh...@panix.com>.
On Sun, 2002-02-03 at 07:53, rob wrote:
> I tried the following
>
> request.setHeader("Content-Disposition", "attachment; filename="mypdf.pdf");
>
> and it seemed to work, is this the correct way or is there a more
> appropriate way to do this?
>
> Thanks
>
That is the correct way. I've had to use a "fake" mime-type to get this
to work with all versions of IE, though (like
"application/x-vnd-yourcompany"). See RFC 2616 for more info:
19.5.1 Content-Disposition
The Content-Disposition response-header field has been proposed as a
means for the origin server to suggest a default filename if the user
requests that the content is saved to a file. This usage is derived from
the definition of Content-Disposition in RFC 1806 [35].
content-disposition = "Content-Disposition" ":"
disposition-type *( ";" disposition-parm )
disposition-type = "attachment" | disp-extension-token
disposition-parm = filename-parm | disp-extension-parm
filename-parm = "filename" "=" quoted-string
disp-extension-token = token
disp-extension-parm = token "=" ( token | quoted-string )
An example is
Content-Disposition: attachment; filename="fname.ext"
--g
--
To unsubscribe: <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>