Could it be that I am writing a text file, where you are writing a zip file ?

On 7/25/05, Arup Vidyerthy <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED]
> Sent: 25 July 2005 14:55
> To: Tomcat Users List; [EMAIL PROTECTED]
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 
> 
> ___________________________________________________________
> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with 
> voicemail http://uk.messenger.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to