Hi Peter,
I came across the exact same problem myself, the OutputStream seems to be
called twice and the Servlet container (I use Tomcat) throws a
IllegalStateException. The problem is fixed simply by invoking the
declareDirectResponse method.
<snip>
aData.declareDirectResponse();
HttpServletResponse lRes = aData.getResponse();
// Setting content type and headers
lRes.setContentType(aContentType);
lRes.setContentLength(aWriter.toString().length());
lRes.setHeader("Content-type", aContentType);
lRes.setHeader("Content-Disposition", "attachment;filename = " + aFileName);
// Get the output stream from the response object
OutputStream lOut = lRes.getOutputStream();
// Using the output stream, push the contents contained within the
StringWriter to the
// user
lOut.write(aWriter.toString().getBytes());
lRes.flushBuffer();
</snip>
-----Original Message-----
From: Henning P. Schmiedehausen [mailto:[EMAIL PROTECTED]
Sent: 19 March 2003 14:12
To: [EMAIL PROTECTED]
Subject: Re: Direct Response and IllegalStateException
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
--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
[EMAIL PROTECTED] +49 9131 50 654 0 http://www.intermeta.de/
Java, perl, Solaris, Linux, xSP Consulting, Web Services
freelance consultant -- Jakarta Turbine Development -- hero for hire
---------------------------------------------------------------------
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]