Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

download and save a zip file from server

 
Udaya Raj
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to downlaod a zip file through the response of a Action class and save it in the client machine. How it can be done.

Regards

Uday
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The easiest way to do this is to create a link to the file. The browser will recognize that the file's suffix is not html, and will ask the user for a location to download it to.

for example:


you could also write a servlet that would read the file and send it as a byte stream, but why go to all that trouble, when a simple link will do the job?

Merrill
 
Eugene Lucash
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do simple forward to zip file (It's worked)
So doing this you can benefit of control
(File download can be selective) and you don't need to worry about
streams and buffering
[ February 24, 2005: Message edited by: Eugene Lucash ]
 
Sean Sullivan
Ranch Hand
Posts: 427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Udaya Raj:
I want to downlaod a zip file through the response of a Action class and save it in the client machine. How it can be done.


Use the ServletOutputStream. Here's an example:

http://strutsblobapp.sourceforge.net/xref/example/struts/FileDownloadAction.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic