struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Baroukh <mbaro...@cardiweb.com>
Subject Re: Downloading file
Date Fri, 03 Nov 2006 16:12:44 GMT

You must use content-disposition header :

response.setHeader("Content-Disposition", "attachment; 
filename=\""+myfilename+"\"");

You can also add a mime type with something like

String mimeType = getServletContext().getMimeType(myfilename);
response.setHeader("Content-Type", 
mimeType==null?"x-type/unknown":mimeType);




Mike

Balwinder a écrit :
> Hi All,
>
> I am developing an application in struts in which I needed to download 
> a file from a server.  When iam clicking on download button, file lose 
> its extension and it with the action ie .do and does not open with the 
> associated application.
>
> Any help is highly appreciated.
>
> Thanks in advance.
>
> Thanks and Regards,
> Balwinder Kumar
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


-- 

Mike Baroukh

---
Cardiweb  - 31 Rue de Mogador Paris IXeme
06 63 57 27 22 - 01 53 21 82 63 - Jabber: mbaroukh@jabber.org
http://www.cardiweb.com
---



Mime
View raw message