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 <[email protected]> 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
>

Reply via email to