Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Download zip or .gz file from server

 
R K Parulekar
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
How to download zip or .gz file from server using servlet or jsp..

Thanks
Ravi
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
R K Parulekar
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic