tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arup Vidyerthy" <>
Subject RE: Internet Explorer and Content-Type
Date Mon, 25 Jul 2005 14:23:16 GMT
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.setHeader("Content-disposition", "attachment; filename=" +
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 =, 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 [] 
Sent: 25 July 2005 14:55
To: Tomcat Users List;
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;

Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message