This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Servlets and the fly likes force download of a binary file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "force download of a binary file" Watch "force download of a binary file" New topic
Author

force download of a binary file

Charles Cayman
Greenhorn

Joined: Jul 02, 2002
Posts: 8
Hi,
I would like to force IE to download a binary file, like a .pdf, or .doc file.
What I do is I call:
res.setContentType("application/octet-stream");
However, IE still displays the contents of the file. What I want is to force the display of a "Save As" dialog box.
How can I go about doing this? Thank you.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

You can use this as well:

/Rene


Regards, Rene Larsen
Dropbox Invite
Charles Cayman
Greenhorn

Joined: Jul 02, 2002
Posts: 8
Hi Rene,
Thanks for the tip, it works!
However, I couldn't find this technique anywhere else. I mean, I have two books (O'reilly and Sun), but they both don't have anything about this Content-disposition header.
What I want to find out is where or how can I know about things like this when get stuck again in the future?
Thanks again in advance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: force download of a binary file
 
Similar Threads
displaying a binary database file
brocken links - Eclipse Live
force download of page
Download content via SMS
Exception