wood burning stoves 2.0*
The moose likes Servlets and the fly likes Empty Downloaded zip file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Empty Downloaded zip file" Watch "Empty Downloaded zip file" New topic
Author

Empty Downloaded zip file

Amy Hafer
Greenhorn

Joined: Mar 29, 2001
Posts: 6
Hi!
I am new to this site but it is by far the most user friendly I have been to. Hoping you can help..
I am writing a servlet that sends a zip file to the user of some files that he/she requested. I am able to create the zip file and write the correct entries to it on the server but all that is available for download is an empty zip file. I think I have major problems understanding output streams.
I was using the
ServletOutputStream out=response.getOutputStream();
I have also tried
PrintWriter out = new PrintWriter(response.getOutputStream());
then I thought all you need is to start the response:
response.setContentType("application/zip");
response.setHeader("Content-Disposition","attachment;filename=" + thefile.getName());
but I don't know how to take the ZipOutputStream or is it the FileOutputStream and send it via out.println()
Any help would be most appreciated!!!
 
Consider Paul's rocket mass heater.
 
subject: Empty Downloaded zip file
 
Similar Threads
Create ZIP file from servlet
Using ServletOutputStream to write contents to a download file
download zipped excel help!!!
UnZip the FormFile
Servlet OutputStream