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 Android Security Essentials Live Lessons this week in the Android 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: 60794
    
  65

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
 
Similar Threads
Error in Dowlnoading
code for file download
Problem with Jar download code in servlet
Doubt in HTTPServletResponse
problem running the download JAR application