You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Alistair Hopkins <al...@berthengron.co.uk> on 2000/08/23 17:57:05 UTC

Naming download files nicely

I've checked my books but I can't find the answer to this one...

I present data as HTML normally [xml processed by xsl] but sometimes, the 
user requests it as csv and it is then processed by different xsl to give 
it in csv format.

How can I set the filename for the dynamically generated file so that excel 
willl open it directly [if they trust me...]?

Thanks,

Al.


RE: Naming download files nicely

Posted by Phuc Truong <pt...@experience.com>.
In terms of opening the file, i agree that the mime type is best (you should
do this regardless).   However, if you want your users to download the file
by right clicking on it, here's what I would do:

1. Create a servlet that returns your results at something like
www.myurl.com/servletzonealias/myservlet

2. Link to the servlet by doing
www.myurl.com/servletzonealias/myservlet/file.xls?myotherarg=foo

3. The server will invoke myservlet passing "file.xls" and the other
arguments to the servlet.

4. However, when the user right clicks on the link to download, the browser
saves as "file.xls".

I've tried this and it works great.

-Phuc

-----Original Message-----
From: Steve Ruby [mailto:steve@rubysolutions.com]
Sent: Wednesday, August 23, 2000 12:41 PM
To: tomcat-user@jakarta.apache.org
Subject: Re: Naming download files nicely


Alistair Hopkins wrote:
>
> I've checked my books but I can't find the answer to this one...
>
> I present data as HTML normally [xml processed by xsl] but sometimes, the
> user requests it as csv and it is then processed by different xsl to give
> it in csv format.
>
> How can I set the filename for the dynamically generated file so that
excel
> willl open it directly [if they trust me...]?
>
> Thanks,
>
> Al.

You should not have to be concerned with the file name, but issue
the proper mime type for an excel file. something like

application/vnd.ms-excel

instead of the usual text/html


Re: Naming download files nicely

Posted by Steve Ruby <st...@rubysolutions.com>.
Alistair Hopkins wrote:
> 
> I've checked my books but I can't find the answer to this one...
> 
> I present data as HTML normally [xml processed by xsl] but sometimes, the
> user requests it as csv and it is then processed by different xsl to give
> it in csv format.
> 
> How can I set the filename for the dynamically generated file so that excel
> willl open it directly [if they trust me...]?
> 
> Thanks,
> 
> Al.

You should not have to be concerned with the file name, but issue
the proper mime type for an excel file. something like

application/vnd.ms-excel

instead of the usual text/html