aspose file tools*
The moose likes JSP and the fly likes File Downloads using servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "File Downloads using servlets " Watch "File Downloads using servlets " New topic
Author

File Downloads using servlets

Chavali Raghu
Greenhorn

Joined: Jul 31, 2002
Posts: 1
Problem downloading a file through the servlet.
The file download happens, but shows only 0 bytes as its content.
sample code of the setting of the headers is shown below:
response.setHeader("Content-Length",String.valueOf(fDownloadFile.length()));
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;Filename=" + fDownloadFile.getName());

Please tell me if the reason for this not happening.
rgds,
Raghu
Peter Storch
Ranch Hand

Joined: Jun 12, 2003
Posts: 74
I don't know about the "Content-Disposition" header.
Don't you have to open the input stream of your file and write the bytes to the response output stream of the servlet yourself?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Downloads using servlets