File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes download file using OutputStream from Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "download file using OutputStream from Servlets" Watch "download file using OutputStream from Servlets" New topic
Author

download file using OutputStream from Servlets

ahmed yehia
Ranch Hand

Joined: Apr 22, 2006
Posts: 424
I want to download a file from a web app using a Servlet and then save the file with its original name and extension, currently Im using ServletOutStream to write data to the response.

The file was successfully downloaded but it's got the Servlet name from which it came from.

I think that could be normal to not identify the file or its extension cause the Servlet is just writing bytes to the stream.

here is the code I use in Servlet:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

Look up the content-disposition response header.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ahmed yehia
Ranch Hand

Joined: Apr 22, 2006
Posts: 424
Thanks Bear Bibeault, it does what I wanted to do.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: download file using OutputStream from Servlets