You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sudip shrestha <su...@gmail.com> on 2005/11/03 18:39:11 UTC

struts download action

I have a struts action that downloads binary files from the database: e.g.:
/actions/download.do?fileId=xxx, etc....
So, whenever users download any type of file with any id, the name of the
file displayed on any browser is "download.do",
is it possible to set something in the response, so that I can supply the
name of the file which the browser displays to the user so that it displays
such as xxx.pdf instead of download.do.

Re: struts download action

Posted by Xavier Vanderstukken <xv...@ionicsoft.com>.
sudip shrestha wrote:

>I have a struts action that downloads binary files from the database: e.g.:
>/actions/download.do?fileId=xxx, etc....
>So, whenever users download any type of file with any id, the name of the
>file displayed on any browser is "download.do",
>is it possible to set something in the response, so that I can supply the
>name of the file which the browser displays to the user so that it displays
>such as xxx.pdf instead of download.do.
>
>  
>
Add this response header :

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



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: struts download action

Posted by Collin VanDyck <co...@hannonhill.com>.
You'll want to do set a header in your response like this:

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

HTH
Collin




sudip shrestha wrote:
> I have a struts action that downloads binary files from the database: e.g.:
> /actions/download.do?fileId=xxx, etc....
> So, whenever users download any type of file with any id, the name of the
> file displayed on any browser is "download.do",
> is it possible to set something in the response, so that I can supply the
> name of the file which the browser displays to the user so that it displays
> such as xxx.pdf instead of download.do.
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org