-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vlad,

On 8/10/12 3:48 AM, Vladimir Mokrozub wrote:
> And here is ErrorHandler servlet: --------------------- 
> @WebServlet("/ErrorHandler") public class ErrorHandler extends
> HttpServlet { protected void doGet(HttpServletRequest request, 
> HttpServletResponse response) throws ServletException, IOException
> { // process exception thrown
> 
> response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 
> (String) request.getAttribute("javax.servlet.error.message")); }
> 
> protected void doPost(HttpServletRequest request, 
> HttpServletResponse response) throws ServletException, IOException
> { doGet(request, response); } } ---------------------
> 
> When I type http://<server-name>/TestServlet in the address bar, I
> get an empty page instead of default Tomcat error page, though the
> status code in the header is correct: "HTTP/1.1 500 Internal Server
> Error".

Try setting the response message explicitly to something unexpected
like "Fruit Loops!" and see if you get that coming back to the client.
I wonder if your code is not being called at all, but "500 Internal
Server Error" is still being returned because there is a real error on
the server.

> And even if I add a custom error page in web.xml like this: 
> --------------------- <error-page> <error-code>500</error-code> 
> <location>/error.html</location> </error-page> 
> --------------------- I still get an empty page instead of
> error.html.
> 
> 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?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlAlH6kACgkQ9CaO5/Lv0PA6VwCfZ6k4ANpBrYytvdNWDY8bjN00
bOEAoJMF67fu0J8qdciUzAfczrl+DMDD
=KYBV
-----END PGP SIGNATURE-----

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

Reply via email to