On 11/08/2012 08:17, Vladimir Mokrozub wrote:
>> On Fri, 10 Aug 2012 10:50:17 -0400
>> Christopher Schultz <ch...@christopherschultz.net> wrote:
> 
>>>
>>> When I try to send error page directly from ErrorHandler using 
>>> HttpServletResponse, it works fine and page is displayed, so it
>>> seems the problem is with sendError() method. Is this an expected
>>> behaviour or some sort of bug?
>>
>> Oh... do you mean there is no content when your ErrorHandler sends the
>> response? Are you producing any content? I certainly don't see a place
>> where you are producing a response document of any kind. What did you
>> expect the client to see on the screen?
>>
> 
> Hi, thanks for the reply.
> 
> 1) I mean if I try to send the response like this:
> -----------------------
> PrintWriter pw = response.getWriter();
> pw.write("<html><body>Error!</body></html>");
> pw.close();
> -----------------------
> it works OK and I see an "Error!" message on the client side.
> 
> 2) If I use sendError() method instead, I don't see anything - just an
> empty page.
> 
> 3) This happens ONLY if the request was forwarded to ErrorHandler
> servlet by Tomcat in case of an error or exception:
> -----------------------
> <error-page>
>       <exception-type>java.lang.Throwable</exception-type>
>       <location>/ErrorHandler</location>
> </error-page>
> <error-page>
>       <error-code>404</error-code>
>       <location>/ErrorHandler</location>
> </error-page>
> -----------------------
> If, for example, I request ErrorHandler directly by URL, I can see an
> error page.
> 
> So I wonder why this happens: is it a bug or my misunderstanding of
> sendError() method?

You are already in an error page so sendError will not trigger the error
page matching process again. If it did there is a strong possibility
that you could end up in an infinite loop.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to