You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Tate Austin <ta...@graysail.com> on 2004/08/30 17:47:19 UTC

Returning a binary object in struts

Maybe some here has implemented something like this before, I am looking for a way to return an actual object in struts.  The Execute method will only do actionforwards and the like, I want to return a pdf file for example, so how does struts allow me to do that?  I have been pouring over the documentation and short of hacking the actual struts code I don't see how its done?

Re: Returning a binary object in struts

Posted by Yves Sy <yv...@gmail.com>.
Hi,

You can either:

a) write a separate servlet for that, a generic one for downloading
binary objects;
b) have Action return null and use the response object instead.

I've tried the first method, but I dont see why the second shouldn't work.

-Yves-

On Mon, 30 Aug 2004 11:47:19 -0400, Tate Austin
<ta...@graysail.com> wrote:
> Maybe some here has implemented something like this before, I am looking for a way to return an actual object in struts.  The Execute method will only do actionforwards and the like, I want to return a pdf file for example, so how does struts allow me to do that?  I have been pouring over the documentation and short of hacking the actual struts code I don't see how its done?


-- 
For me to poop on!
http://www.formetopoopon.com
http://www.nbc.com/nbc/Late_Night_with_Conan_O'Brien/video/triumph.shtml

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


Re: Returning a binary object in struts

Posted by Nick Heudecker <nh...@gmail.com>.
Basically, you return null from your execute(...) method and use the
response object to stream the binary object down.

I think the steps are:
1) Set the content type
2) Get the ServletOutputStream
3) Write your bytes to it
4) Flush and close the stream

I'm not sure about the steps since we wrote a simple utility class to do this.  


On Mon, 30 Aug 2004 11:47:19 -0400, Tate Austin
<ta...@graysail.com> wrote:
> Maybe some here has implemented something like this before, I am looking for a way to return an actual object in struts.  The Execute method will only do actionforwards and the like, I want to return a pdf file for example, so how does struts allow me to do that?  I have been pouring over the documentation and short of hacking the actual struts code I don't see how its done?

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