This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Servlets and the fly likes Sending a ZIP file in Servlet response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sending a ZIP file in Servlet response" Watch "Sending a ZIP file in Servlet response" New topic
Author

Sending a ZIP file in Servlet response

trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
In my module, I create a file, then ZIp it. I want to send this zipped file in servlet response.
Here is what I do in my code.

public static final String DEFAULT_CONTENT_TYPE = "application/octet-stream";
public static final int LENGTH_OF_ZIPDATA = 2048;


How do I send the ZipOutputStream in the response. The way I am sending it is incorrect cause converting it to string will not help in this case. I am not sure how to achieve this. Need some pointers.
Thanks,
Trupti
trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
I think I got the answer to my above question. This is how I achieved it.

thanks,
Trupti
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Sending a ZIP file in Servlet response
 
Similar Threads
Specifting zip file name in servlet
Appending Content to a file Inside a zip file
ZipOutputStream
zip files without path info...
Create ZIP file from servlet