This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 14687

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

Might want to review:

They have some tips for how to help with IE.

My Blog: Down Home Country Coding with Scott Selikoff
I agree. Here's the link:
subject: Content-Disposition: Download file name problem
Similar Threads
word doc servlet filename question
response.setHeader("Content-Disposition") not working in IE alone
File download with servlets
file downoad [browser issue]
Export to excel question