click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henry Saputra <henry.sapu...@gmail.com>
Subject Re: getOutputStream() has already been called for this response
Date Sat, 13 Mar 2010 07:25:33 GMT
HI Bob,

Looks like we cant call getWriter when getOutputStream has been called to
write to body in a same request.

Maybe we could catch IllegalStateException when calling request.getWriter
and the code could redirect with something like
          response.sendRedirect(request.getContextPath() +
"/click/error.htm")
, OR fallback to use ServletOutputStream if IllegalStateException is
triggered during call to getWriter:
             new OutputStreamWriter(response.getOutputStream(),
response().getCharacterEncoding());

- Henry

On Fri, Mar 12, 2010 at 8:57 PM, Bob Schellink <sabob1@gmail.com> wrote:

> Hi all,
>
> In our applications we often render PDF's to the response's outputStream.
> Click templates of the other hand uses the response's writer.
>
> If an exception is thrown after response.getOutputStream is called, Click
> will try and render the ErrorPage using the response.getWriter which leads
> to the exception:
>
>  getOutputStream() has already been called for this response
>
> Is there an easy way to determine whether its safe to invoke getWriter?
>
> kind regards
>
> bob
>

Mime
View raw message