You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Eric Hamacher <er...@enetrix.com> on 2008/07/02 20:10:21 UTC

zipping files for download

Hello:

 

I started writing a Struts 2 action which zips up the contents of a
directory on the filesystem and downloads it.  Everything was fine until
I discovered that java.util.zip.ZipOutputStream requires an OutputStream
in its constructor.  It doesn't seem like a good idea to get a reference
to the ServletOutputStream in my action and then use StreamResult later
on (if that is even necessary).  On the other hand, I could do the
zipping within a custom result but this also seems inappropriate.  The
ideal solution would be to have a custom result which somehow receives
from the action some type of object which contains Files in a tree
hierarchy.  I don't know, I'm new to Struts 2 so any feedback on this
matter would be appreciated.

 

Regards,

Eric Hamacher

 

******************************

THIS EMAIL IS INTENDED ONLY FOR THE REVIEW OF THE ADDRESSEE(S), AND MAY
CONTAIN CONFIDENTIAL AND LEGALLY PRIVILEGED INFORMATION. INTERCEPTION,
COPYING, DISSEMINATION, OR OTHER USE BY OTHER THAN THE ADDRESSEE(S) IS
PROHIBITED AND MAY BE PENALIZED UNDER APPLICABLE PRIVACY LAWS. IF YOU
RECEIVED THIS EMAIL IN ERROR, PLEASE DELETE IT AND NOTIFY ME BY RETURN
EMAIL TO eric.hamacher@enetrix.com *******************************

 


RE: zipping files for download

Posted by Eric Hamacher <er...@enetrix.com>.
I said :

"The ideal solution would be to have a custom result which somehow
receives from the action some type of object which contains Files in a
tree hierarchy."

I did just that.  I invented an object "Directory" which holds files and
other "directories".  My action assembled this object.  My result took
the object, recursed through it, and created a zip to stream.

Thinking out loud, I guess.

-----Original Message-----
From: Roger [mailto:roger.varley@googlemail.com] 
Sent: Wednesday, July 02, 2008 3:57 PM
To: Struts Users Mailing List
Subject: Re: zipping files for download

On Wednesday 02 July 2008 23:44:16 Eric Hamacher wrote:
> Followed my instincts, problem is solved. No need to reply!
>

So what did your instinct tell you?



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: zipping files for download

Posted by Roger <ro...@googlemail.com>.
On Wednesday 02 July 2008 23:44:16 Eric Hamacher wrote:
> Followed my instincts, problem is solved. No need to reply!
>

So what did your instinct tell you?



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: zipping files for download

Posted by Eric Hamacher <er...@enetrix.com>.
Followed my instincts, problem is solved. No need to reply!

-----Original Message-----
From: Eric Hamacher [mailto:eric.hamacher@enetrix.com] 
Sent: Wednesday, July 02, 2008 1:10 PM
To: Struts Users Mailing List
Subject: zipping files for download

Hello:

 

I started writing a Struts 2 action which zips up the contents of a
directory on the filesystem and downloads it.  Everything was fine until
I discovered that java.util.zip.ZipOutputStream requires an OutputStream
in its constructor.  It doesn't seem like a good idea to get a reference
to the ServletOutputStream in my action and then use StreamResult later
on (if that is even necessary).  On the other hand, I could do the
zipping within a custom result but this also seems inappropriate.  The
ideal solution would be to have a custom result which somehow receives
from the action some type of object which contains Files in a tree
hierarchy.  I don't know, I'm new to Struts 2 so any feedback on this
matter would be appreciated.

 

Regards,

Eric Hamacher

 

******************************

THIS EMAIL IS INTENDED ONLY FOR THE REVIEW OF THE ADDRESSEE(S), AND MAY
CONTAIN CONFIDENTIAL AND LEGALLY PRIVILEGED INFORMATION. INTERCEPTION,
COPYING, DISSEMINATION, OR OTHER USE BY OTHER THAN THE ADDRESSEE(S) IS
PROHIBITED AND MAY BE PENALIZED UNDER APPLICABLE PRIVACY LAWS. IF YOU
RECEIVED THIS EMAIL IN ERROR, PLEASE DELETE IT AND NOTIFY ME BY RETURN
EMAIL TO eric.hamacher@enetrix.com *******************************

 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org