tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hooper, Brian" <brian.hoo...@lmco.com>
Subject RE: HELP: Servlet File Download solution.
Date Wed, 14 Jan 2004 14:07:44 GMT
This probably doesn't matter, but try this instead:

response.setHeader("Content-Disposition",
  "attachment;filename=\"" + myFileName + "\"");
// Removed the space in between "attachment;" and "filename"
response.setContentType("application/octet-stream");
// I don't think you need to specify the filename again

Using the above seems to work for me, but I'm not sure if a user with
IE5 has tried it.  What happens when you use it in IE5?  Error message?
Data output to the screen?  Empty file?

It might be a MIME problem also.

-Brian

-----Original Message-----
From: Rai Ou [mailto:ourai@veritrans.co.jp] 
Sent: Tuesday, January 13, 2004 9:45 PM
To: 'Tomcat Users List'
Subject: HELP: Servlet File Download solution.


I wrote a download servlet but I found it didn't run at IE5.x

IE6.x - OK
IE5.x - NG
NS - OK

My source is below. I want to know if there are better solutions or any
Common Libarary I can use.

response.setHeader("Content-Disposition",
  "attachment; filename=\"" + myFileName + "\"");
response.setContentType("application/octet-stream;
  name=\"" + myFileName + "\"");
String f = myFilePath;
PrintWriter out = response.getWriter();
BufferedReader in 
    = new BufferedReader(new FileReader(f));
String line;
while ((line = in.readLine()) != null) {
   out.println(line);
}
in.close();

Thanks.
Rai



---------------------------------------------------------------------
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