dev@glassfish.java.net

Servlet error pages and sendError, setStatus

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 15 Oct 2009 14:48:52 +0200

Hi,

Attached is a simple Web application with two servlets and a JSP error
page for 404 response status codes.

The SetStatusServlet does the following when servicing a request:

         response.addHeader("X-FOO", "foo");
         response.setStatus(404);

The SendErrorServlet does the following when servicing a request:

         response.addHeader("X-FOO", "foo");
         response.sendError(404);


I used GF v3 preview for testing with the following results:

1) When SetStatusServlet serves the request the default GF 404 error
page is returned, not the error page
      declared in the web.xml. The X-FOO header is present.

2) When SendErrorServlets serves the request the error page declared
in the web.xml is returned. The X-FOO
     header is not present.

Is this an issue or a spec requirement.

If this is a spec requirement should we have a GF feature to relax
this. So when say a response is returned with no response entity (no
bytes written to the servlet response output stream) that error pages
can be invoked.

Paul.