[thelist] Anyway to set filename through response header?

Matt Warden mwarden at gmail.com
Wed Aug 18 13:48:16 CDT 2004


On Wed, 18 Aug 2004 14:18:59 -0400, Chris Johnston
<fuzzylizard at gmail.com> wrote:
> Hello,
> 
> One more question concerning response headers. I am using struts and
> java to server up an excel file. However, when the user gets the file
> (which currently opens in their browser) the file is called
> createReport.do. Is there anyway, using the response header, to change
> the filename to foo.xls?

Send this header:

Content-Disposition: attachment; filename="filename.xls"

It suggests a recommended filename. It does not work in IE4 (4.01?) or IE5.5.

When I did this, I just mapped filename.xls to my servlet in Tomcat's
web.xml. I felt it was better than relying on this header.


-- 
mattwarden
mattwarden.com


This email proudly and graciously contributes to entropy.


More information about the thelist mailing list