tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tõnu Põld <Tonu.Po...@andmevara.ee>
Subject RE: default file name in download
Date Thu, 18 Jan 2001 07:11:53 GMT
Hi,

Try the "Content-disposition" header.
It seems to work with MS Internet Explorer and Netscape browsers - I have
not tested others.

If you want to return a RTF file named MyFilename.rtf, it could be done like
this:

class MyServlet extends javax.servlet.http.HttpServlet{
...
  public void doGet(HttpServletRequest req,HttpServletResponse res)
	throws javax.servlet.ServletException, java.io.IOException{
                        ...
		res.setContentType("text/rtf");
		res.setHeader("Content-disposition",
"filename=MyFilename.rtf");
                        ...
  }
}

Regards,
Tõnu

> -----Original Message-----
> From: cga [mailto:cga@ciudad.com.ar]
> Sent: Thursday, January 18, 2001 6:44 AM
> To: tomcat-user@jakarta.apache.org
> Subject: default file name in download
> 
> 
> Hi there,
> 
>     I am doing a servlet that presents the output in two 
> flawors. The first
> one is a html page, I use a jsp.
>     The second one is a downloable file which I generate 
> throught a jsp.
> Changing the content-type is easy. But I would like to give the file a
> download name. I mean, when the user clicks on the save 
> button he would have
> a default name that I will give. I mean, something like 
> 'usefuldata.dat'
> instead of 'MyServlet'.
>     Does anybody knows how to do it?
> 
> Thanks in advance,
> 
> Carlos Gaston Alvarez
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org
> 

Mime
View raw message