When I need to use the ServletOutputStream directly, I extend a screen from
RawScreen. That RawScreen has been very useful to me. Still, I think we are
removing it from Turbine 2.3. Hope I am wrong...

Rodrigo

----- Original Message -----
From: "Peter Courcoux" <[EMAIL PROTECTED]>
To: "Turbine Developers List" <[EMAIL PROTECTED]>
Sent: Wednesday, March 19, 2003 3:19 PM
Subject: Re: Direct Response and IllegalStateException


> Henning,
>
>
> On Wed, 2003-03-19 at 13:12, Henning P. Schmiedehausen wrote:
> > Peter Courcoux <[EMAIL PROTECTED]> writes:
> >
> > >Hi all,
> >
> > >I have recently changed from using turbine 2.2-b3 to 2.2.1 and from
> > >using VelocityECSLayout to VelocityOnlyLayout.
> >
> > Actually, I'm getting more and more unhappy with the deprecation of
> > VelocityECSLayout. There seem to be many quirks that can't be fixed
> > in a clean manner. We might have to think about this a little more.
> >
> > >One of my actions which extends VelocitySecureAction handles a file
> > >download by obtaining the HttpServletResponse setting the headers and
> > >then obtaining and writing directly to the ServletOutputStream.
> >
> > >Before the changes outlined above this caused no problem. Having made
> > >the changes the following Exception occurs after the completion of the
> > >download and closing the ServletOutputStream.
> >
> > Could you please post some code snippets. How do you do the file
> > download? Directly from the action (you shouldn't do that) or do you
> > have a screen which does the download to which you redirect? I'm
> > getting a little scared by reading that you try to manipulate the
> > Servlet output stream by yourself. :-)
> >
> > Regards
> > Henning
>
> As mentioned off-list, I have a need to build a zip file of multiple
> download files and the easiest way I have found is to directly
> manipulate the ServletOutputStream. This also applies where I am
> building images for embedding within pages of data.
>
> I have solved this by creating a DirectResponseLayout class which does
> nothing except check that declareDirectResponse() has been called on
> RunData. I then call
>
> data.setLayout("DirectResponseLayout");
>
> in my Action class.
>
> Source of DirectResponseLayout :-
>
> package com.whatever.modules.layouts;
>
> // Turbine Classes
> import org.apache.turbine.modules.Layout;
> import org.apache.turbine.util.RunData;
>
> /**
>  * This layout allows an action to manipulate the
>  * ServletOutputStream directly. It requires that
>  * data.declareDirectResponse() has been called to
>  * indicate that the OutputStream is being
>  * handled else an Exception is thrown
>  *
>  * @author <a href="mailto:[EMAIL PROTECTED]">Peter Courcoux</a>
>  */
> public class DirectResponseLayout extends Layout
> {
>     /**
>      * Method called by LayoutLoader.
>      *
>      * @param RunData
>      */
>     public void doBuild( RunData data ) throws Exception
>     {
>         if (!data.isOutSet())
>             {
>                 throw new Exception(
>                     "data.declareDirectResponse() has not been called");
>             }
>     }
> }
>
>
>
> One drawback is that it calls data.isOutSet() which is deprecated.
>
> Questions.
>
> 1. Is there a better way?
> 2. If not, would it be worth including the DirectResponseLayout class in
>   the turbine distribution.
> 3. Is there a case for removing the deprecation of RunData.isOutSet()?
> 4. Is this worth documenting. At least one other user appears to be
> doing something similar.
>
> Regards
>
> Peter
> --
> Peter Courcoux <[EMAIL PROTECTED]>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to