You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Anatoli Krassavine <an...@yahoo.co.uk> on 2005/03/17 16:29:47 UTC
Suppressing page response - simply override the output stream manually
Hello,
Sorry for chipping in late, but I am surprised that
no one mentioned the simplest and cheapest approach:
manually get hold of HttpResponse output stream and
write to it and then close it. Tapestry will not
attempt to re-open the stream.
I grant that it is based on inside knowledge of
specific current implementation of Tapestry, but I
doubt Howard is going to change it.
See code below - I used it successfully in several
projects.
public void myListener(IRequestCycle cycle)
{
RequestContext requestContext =
cycle.getRequestContext();
HttpServletResponse response =
requestContext.getResponse();
// set various headers
response.setHeader("Content-disposition", ....);
response.setHeader("Content-Length", ....);
try
{
response.setContentType(<appropriate type>);
OutputStream os = response.getOutputStream();
os.write(.....);
// It is VERY important to close the stream at the
end.
os.close();
}
catch(Exception e)
{
// do something
}
}
Cheers,
Toly
Anatoli Krassavine
Send instant messages to your online friends http://uk.messenger.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Suppressing page response - simply override the output stream
manually
Posted by Andreas Andreou <an...@di.uoa.gr>.
Anatoli Krassavine wrote:
> Hello,
>
> Sorry for chipping in late, but I am surprised that
>no one mentioned the simplest and cheapest approach:
>manually get hold of HttpResponse output stream and
>write to it and then close it. Tapestry will not
>attempt to re-open the stream.
>
>
Others have also reported this, but it just didn't work for me (when I
last tried)!
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org