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 Struts and the fly likes download zip file in struts 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 » Frameworks » Struts
Bookmark "download zip file in struts" Watch "download zip file in struts" New topic

download zip file in struts

RaviSingh Kumar
Ranch Hand

Joined: Sep 04, 2007
Posts: 52

I newbee in struts. I have a link in jsp page "Dowload Zip file" which call an action class.

I want action class to zip the entire content of the specified directory and send zip file for downloading.

Please help in order to proceed.

Thanks in advance.
Pramod Chris

Joined: Oct 15, 2004
Posts: 21
If you need info on how to zip files, then do take a look at the pacakage.

On another note, this really isn't struts related.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902

In Action class:
1. Using File class, read the each file
2. Using ZipOutputStream Java API, zip them.
3. Send the resulted zip file stream to the response output OR save the resulted zip file on server and then simply give link to that file.

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
I agree. Here's the link:
subject: download zip file in struts
Similar Threads
struts 1.2,Spring 2.0 INtrgration
Doubt in struts-config.xml?
download and save a zip file from server
can some .zip files (not java classes) be included in WEB-INF/classes too ?
UnZip the FormFile