dev@glassfish.java.net

Re: Servlet error pages and sendError, setStatus

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

On Oct 15, 2009, at 2:48 PM, Paul Sandoz wrote:

> 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:
>

Correction, i used GF v3 Prelude.

GF v2.1 has the same behavior.

Same for Tomcat and GF v3 b66 except that the X-FOO response header is
present in both case.

Paul.

> 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.
>
> <
> WebApplication15
> .zip
> >---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net