tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark <elihusma...@gmail.com>
Subject Re: Internet Explorer and Content-Type
Date Mon, 25 Jul 2005 14:28:47 GMT
Could it be that I am writing a text file, where you are writing a zip file ?

On 7/25/05, Arup Vidyerthy <like_donuts@yahoo.co.uk> wrote:
> Strange... I have identical code and it works IE and FireFox.
> 
> This is how write it out into the response stream
> 
> // set up the response header with the content type, the file name and
> // the file size
> //
> res.setContentType("application/zip");
> res.setHeader("Content-disposition", "attachment; filename=" +
> file.getName());
> res.setHeader("Content-Length", String.valueOf(file.length()));
> 
> // create a URL object for the tmp file, create the input stream from
> // the URL
> //
> URL url = getServletContext().getResource(filename);
> input = new BufferedInputStream(url.openStream());
> 
> // read from the file, write to the servlet output stream
> //
> byte[] buff = new byte[1024];
> int bytesRead;
> while (-1 != (bytesRead = input.read(buff, 0, buff.length))) {
>         output.write(buff, 0, bytesRead);
> }
> 
> 
> The only difference I can see is how I use lowercase but I don't see why
> that should make any difference.
> 
> 
> 
> -----Original Message-----
> From: Mark [mailto:elihusmails@gmail.com]
> Sent: 25 July 2005 14:55
> To: Tomcat Users List; elihusmails@gmail.com
> Subject: Internet Explorer and Content-Type
> 
> I have a servlet that generates data that I want to write to the client's
> browser.  This data is just ASCII text.  The problem that I am running into
> is that Internet Explorer's "Save As" window defaults the filename to the
> name of my servlet.  Firefox/Netscape will save the file as the filename
> that I specify in the Content-Type HTTP header.
> Does anyone know how to fix this?
> 
> Here is the code that I am currently using:
> 
> response.setContentType("text/xyz" );
> response.setHeader("Content-Disposition", "Attachment;
> filename=\"blah.xyz\"");
> 
> Thank you.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 
> 
> 
> ___________________________________________________________
> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
>

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


Mime
View raw message