users@glassfish.java.net

Re: Downloading Files-how to open the File Download Dialog

From: Craig Ringer <craig_at_postnewspapers.com.au>
Date: Fri, 10 Sep 2010 14:35:06 +0800

On 09/10/2010 02:13 PM, glassfish_at_javadesktop.org wrote:
> In my web application,I want to use hypertext link to download file.
> when I execute the following code, the file is opened by IE.
> <a href="./test.pdf">download</a>
>
> but I want to open the File Download Dialog, how to set in the glassfish? I attempt to use the following code,but it did not work.
> dir\domains\domain1\config\default-web.xml
> <mime-mapping>
> <extension>pdf</extension>
> <mime-type>application/octet-stream</mime-type>
> </mime-mapping>

MSIE has the nasty habit of ignoring MIME types and preferring file
extensions in *some* situations. Last time I dealt with it - admittedly
some time ago - it was rather inconsistent about when it relied on file
extension and when it used MIME type.

IIRC I solve it with a MIME content-disposition: attachment header, but
that was some time ago, pre-glassfish for me.

--
Craig Ringer