wood burning stoves*
The moose likes Servlets and the fly likes Download zip or .gz file from server 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 zip or .gz file from server" Watch "Download zip or .gz file from server" New topic
Author

Download zip or .gz file from server

R K Parulekar
Ranch Hand

Joined: May 29, 2005
Posts: 66
Hi
How to download zip or .gz file from server using servlet or jsp..

Thanks
Ravi


"A wish changes nothing. A decision changes everything." - Unknown
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Ravi,
You mean download through the user's browser, right? Have your servlet set the MIME type for compressed/zip files and then output the binary data just like you would have output the HTML.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
R K Parulekar
Ranch Hand

Joined: May 29, 2005
Posts: 66
Thanks Jeanne
Yes you r right, it's download thru user's browser..
When user clicks download data link (browser) ..

My programme generates a csv file and same is downloaded to the client...
Now ,what i want,instaed of downloading csv file I want to zip and download it..

My code looks like ...

res.setHeader("Content-Encoding", "gzip");
res.setHeader("Content-Disposition", "attachment;filename=\"" + fileName "\"");
javax.servlet.ServletOutputStream servletoutputstream
= res.getOutputStream();
GZIPOutputStream gzipoutputstream
= new GZIPOutputStream ( servletoutputstream);
...


Any suggestions !!

Ravi..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Download zip or .gz file from server
 
Similar Threads
Access the entry such as entry filename in gzip file
Unable to dowload the Servlet 2.4 specs.
downloading Tomcat
download zip in jsp
Can't find bin directory...