File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Content-Disposition: Download file name problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Content-Disposition: Download file name problem" Watch "Content-Disposition: Download file name problem" New topic

Content-Disposition: Download file name problem

Shanu Paul

Joined: Aug 19, 2006
Posts: 2

In my servlet I am trying to let the user download a file using the following code:

response.setHeader("Content-Disposition","attachment; filename=wordfile.doc");

This works fine in Netscape, but when trying to do this in IE (including IE 6.0) the filename is the name of the servlet and not the file name specified. Is there anyway to fix this? If IE cannot handle the Content-Disposition correctly, is there any other way other than using Content-Disposition to handle it.

Please let me know. Many thanks.

Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Did you try with double quotations around the filename ?

[My Blog]
All roads lead to JavaRanch
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

Might want to review:

They have some tips for how to help with IE.

[OCA 8 Book] [Blog]
I agree. Here's the link:
subject: Content-Disposition: Download file name problem
It's not a secret anymore!