tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Suen" <stephen.s...@gmail.com>
Subject Re: Catching RequestDispatcher not found errors
Date Sat, 20 May 2006 01:15:55 GMT
On 5/19/06, Mark Thomas <markt@apache.org> wrote:
>
>
> The RequestDispatcher is created in this class:
>
> http://svn.apache.org/repos/asf/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationContext.java
>
> ApplicationDispatcher implements RequestDispatcher
>
> http://svn.apache.org/repos/asf/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java
>
> The wrapper that checks if it is included before calling sendError is
>
> http://svn.apache.org/repos/asf/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationHttpResponse.java
>
> HTH,
>
> Mark



Thanks for your help.

Acording to the API, sendError from the *included servlet* will be ignored.
I think maybe this doesn't necessarily mean *Tomcat itself* can't do it. If
i'm trying to include a resource not existed after the response being
committed, the error message will be appended to the response, and sendError
be ignored.

Here's the snippet from
http://svn.apache.org/repos/asf/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java
:

    if (requestUri == null) {
        requestUri = request.getRequestURI();
    } else {
        // We're included, and the response.sendError() below is going
        // to be ignored by the resource that is including us.
        // Therefore, the only way we can let the including resource
        // know is by including warning message in response
        response.getWriter().write(
            sm.getString("defaultServlet.missingResource ",
            requestUri));
    }

    response.sendError(HttpServletResponse.SC_NOT_FOUND,
                       requestUri);

If the response has already been committed, doing that will get a 404 error
page returned to the client, that means Tomcat set this status somewhere
else, or from some wrapper, but I failed to find it.

Any idea?

Best Regards

Stephen
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message