org.apache.catalina.deploy.ErrorPage Java Examples

The following examples show how to use org.apache.catalina.deploy.ErrorPage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StandardHostValve.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Find and return the ErrorPage instance for the specified exception's
 * class, or an ErrorPage instance for the closest superclass for which
 * there is such a definition.  If no associated ErrorPage instance is
 * found, return <code>null</code>.
 *
 * @param context The Context in which to search
 * @param exception The exception for which to find an ErrorPage
 */
private static ErrorPage findErrorPage
    (Context context, Throwable exception) {

    if (exception == null)
        return (null);
    Class<?> clazz = exception.getClass();
    String name = clazz.getName();
    while (!Object.class.equals(clazz)) {
        ErrorPage errorPage = context.findErrorPage(name);
        if (errorPage != null)
            return (errorPage);
        clazz = clazz.getSuperclass();
        if (clazz == null)
            break;
        name = clazz.getName();
    }
    return (null);

}
 
Example #2
Source File: StandardHostValve.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Find and return the ErrorPage instance for the specified exception's
 * class, or an ErrorPage instance for the closest superclass for which
 * there is such a definition.  If no associated ErrorPage instance is
 * found, return <code>null</code>.
 *
 * @param context The Context in which to search
 * @param exception The exception for which to find an ErrorPage
 */
private static ErrorPage findErrorPage
    (Context context, Throwable exception) {

    if (exception == null)
        return (null);
    Class<?> clazz = exception.getClass();
    String name = clazz.getName();
    while (!Object.class.equals(clazz)) {
        ErrorPage errorPage = context.findErrorPage(name);
        if (errorPage != null)
            return (errorPage);
        clazz = clazz.getSuperclass();
        if (clazz == null)
            break;
        name = clazz.getName();
    }
    return (null);

}
 
Example #3
Source File: TestAsyncContextImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Test
public void testTimeoutDispatchCustomErrorPage() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    Context context = tomcat.addContext("", null);
    tomcat.addServlet("", "timeout", Bug58751AsyncServlet.class.getName())
            .setAsyncSupported(true);
    CustomErrorServlet customErrorServlet = new CustomErrorServlet();
    Tomcat.addServlet(context, "customErrorServlet", customErrorServlet);
    context.addServletMapping("/timeout", "timeout");
    context.addServletMapping("/error", "customErrorServlet");
    ErrorPage errorPage = new ErrorPage();
    errorPage.setLocation("/error");
    context.addErrorPage(errorPage);
    tomcat.start();

    ByteChunk responseBody = new ByteChunk();
    int rc = getUrl("http://localhost:" + getPort() + "/timeout", responseBody, null);

    Assert.assertEquals(503, rc);
    Assert.assertEquals(CustomErrorServlet.ERROR_MESSAGE, responseBody.toString());
}
 
Example #4
Source File: DebugTomcat.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    setupDebugEnv();

    int port = 7070;
    if (args.length >= 1) {
        port = Integer.parseInt(args[0]);
    }

    File webBase = new File("../webapp/app");
    File webInfDir = new File(webBase, "WEB-INF");
    FileUtils.deleteDirectory(webInfDir);
    FileUtils.copyDirectoryToDirectory(new File("../server/src/main/webapp/WEB-INF"), webBase);

    Tomcat tomcat = new Tomcat();
    tomcat.setPort(port);
    tomcat.setBaseDir(".");

    // Add AprLifecycleListener
    StandardServer server = (StandardServer) tomcat.getServer();
    AprLifecycleListener listener = new AprLifecycleListener();
    server.addLifecycleListener(listener);

    Context webContext = tomcat.addWebapp("/kylin", webBase.getAbsolutePath());
    ErrorPage notFound = new ErrorPage();
    notFound.setErrorCode(404);
    notFound.setLocation("/index.html");
    webContext.addErrorPage(notFound);
    webContext.addWelcomeFile("index.html");

    // tomcat start
    tomcat.start();
    tomcat.getServer().await();
}
 
Example #5
Source File: DebugTomcat.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    setupDebugEnv();

    int port = 7070;
    if (args.length >= 1) {
        port = Integer.parseInt(args[0]);
    }

    File webBase = new File("../webapp/app");
    File webInfDir = new File(webBase, "WEB-INF");
    FileUtils.deleteDirectory(webInfDir);
    FileUtils.copyDirectoryToDirectory(new File("../server/src/main/webapp/WEB-INF"), webBase);

    Tomcat tomcat = new Tomcat();
    tomcat.setPort(port);
    tomcat.setBaseDir(".");

    // Add AprLifecycleListener
    StandardServer server = (StandardServer) tomcat.getServer();
    AprLifecycleListener listener = new AprLifecycleListener();
    server.addLifecycleListener(listener);

    Context webContext = tomcat.addWebapp("/kylin", webBase.getAbsolutePath());
    ErrorPage notFound = new ErrorPage();
    notFound.setErrorCode(404);
    notFound.setLocation("/index.html");
    webContext.addErrorPage(notFound);
    webContext.addWelcomeFile("index.html");

    // tomcat start
    tomcat.start();
    tomcat.getServer().await();
}
 
Example #6
Source File: TestStandardHostValve.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testErrorPageHandling() throws Exception {
    // Set up a container
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    // Add the error page
    Tomcat.addServlet(ctx, "error", new ErrorServlet());
    ctx.addServletMapping("/error", "error");

    // Add the error handling page
    Tomcat.addServlet(ctx, "report", new ReportServlet());
    ctx.addServletMapping("/report/*", "report");

    // And the handling for 500 responses
    ErrorPage errorPage500 = new ErrorPage();
    errorPage500.setErrorCode(Response.SC_INTERNAL_SERVER_ERROR);
    errorPage500.setLocation("/report/500");
    ctx.addErrorPage(errorPage500);

    // And the default error handling
    ErrorPage errorPageDefault = new ErrorPage();
    errorPageDefault.setLocation("/report/default");
    ctx.addErrorPage(errorPageDefault);

    tomcat.start();

    doTestErrorPageHandling(500, "/500");
    doTestErrorPageHandling(501, "/default");
}
 
Example #7
Source File: TestStandardHostValve.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testErrorPageHandling() throws Exception {
    // Set up a container
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    // Add the error page
    Tomcat.addServlet(ctx, "error", new ErrorServlet());
    ctx.addServletMapping("/error", "error");

    // Add the error handling page
    Tomcat.addServlet(ctx, "report", new ReportServlet());
    ctx.addServletMapping("/report/*", "report");

    // And the handling for 500 responses
    ErrorPage errorPage500 = new ErrorPage();
    errorPage500.setErrorCode(Response.SC_INTERNAL_SERVER_ERROR);
    errorPage500.setLocation("/report/500");
    ctx.addErrorPage(errorPage500);

    // And the default error handling
    ErrorPage errorPageDefault = new ErrorPage();
    errorPageDefault.setLocation("/report/default");
    ctx.addErrorPage(errorPageDefault);

    tomcat.start();

    doTestErrorPageHandling(500, "/500");
    doTestErrorPageHandling(501, "/default");
}
 
Example #8
Source File: TestStandardHostValve.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test(expected=IllegalArgumentException.class)
public void testInvalidErrorPage() throws Exception {
    // Set up a container
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    // Add a broken error page configuration
    ErrorPage errorPage500 = new ErrorPage();
    errorPage500.setErrorCode("java.lang.Exception");
    errorPage500.setLocation("/report/500");
    ctx.addErrorPage(errorPage500);
}
 
Example #9
Source File: TestAsyncContextImpl.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
private void doTestTimeoutErrorDispatch(Boolean asyncError,
        ErrorPageAsyncMode mode) throws Exception {
    resetTracker();
    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    TimeoutServlet timeout = new TimeoutServlet(null, null);
    Wrapper w1 = Tomcat.addServlet(ctx, "time", timeout);
    w1.setAsyncSupported(true);
    ctx.addServletMapping("/async", "time");

    NonAsyncServlet nonAsync = new NonAsyncServlet();
    Wrapper w2 = Tomcat.addServlet(ctx, "nonAsync", nonAsync);
    w2.setAsyncSupported(true);
    ctx.addServletMapping("/error/nonasync", "nonAsync");

    AsyncErrorPage asyncErrorPage = new AsyncErrorPage(mode);
    Wrapper w3 = Tomcat.addServlet(ctx, "asyncErrorPage", asyncErrorPage);
    w3.setAsyncSupported(true);
    ctx.addServletMapping("/error/async", "asyncErrorPage");

    if (asyncError != null) {
        ErrorPage ep = new ErrorPage();
        ep.setErrorCode(500);
        if (asyncError.booleanValue()) {
            ep.setLocation("/error/async");
        } else {
            ep.setLocation("/error/nonasync");
        }

        ctx.addErrorPage(ep);
    }

    ctx.addApplicationListener(TrackingRequestListener.class.getName());

    TesterAccessLogValve alv = new TesterAccessLogValve();
    ctx.getPipeline().addValve(alv);
    TesterAccessLogValve alvGlobal = new TesterAccessLogValve();
    tomcat.getHost().getPipeline().addValve(alvGlobal);

    tomcat.start();
    ByteChunk res = new ByteChunk();
    try {
        getUrl("http://localhost:" + getPort() + "/async", res, null);
    } catch (IOException ioe) {
        // Ignore - expected for some error conditions
    }

    StringBuilder expected = new StringBuilder();
    expected.append("requestInitialized-TimeoutServletGet-");
    if (asyncError != null) {
        if (asyncError.booleanValue()) {
            expected.append("AsyncErrorPageGet-");
            if (mode == ErrorPageAsyncMode.NO_COMPLETE){
                expected.append("NoOp-");
            } else if (mode == ErrorPageAsyncMode.COMPLETE) {
                expected.append("Complete-");
            } else if (mode == ErrorPageAsyncMode.DISPATCH) {
                expected.append("Dispatch-NonAsyncServletGet-");
            }
        } else {
            expected.append("NonAsyncServletGet-");
        }
    }
    expected.append("requestDestroyed");

    // Request may complete before listener has finished processing so wait
    // up to 5 seconds for the right response
    String expectedTrack = expected.toString();
    int count = 0;
    while (!expectedTrack.equals(getTrack()) && count < 100) {
        Thread.sleep(50);
        count ++;
    }
    Assert.assertEquals(expectedTrack, getTrack());

    // Check the access log
    alvGlobal.validateAccessLog(1, 500, TimeoutServlet.ASYNC_TIMEOUT,
            TimeoutServlet.ASYNC_TIMEOUT + TIMEOUT_MARGIN +
            REQUEST_TIME);
    alv.validateAccessLog(1, 500, TimeoutServlet.ASYNC_TIMEOUT,
            TimeoutServlet.ASYNC_TIMEOUT + TIMEOUT_MARGIN +
            REQUEST_TIME);
}
 
Example #10
Source File: TestAsyncContextImpl.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
private void doTestBug51197(boolean threaded, boolean customError) throws Exception {
    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    AsyncErrorServlet asyncErrorServlet =
        new AsyncErrorServlet(HttpServletResponse.SC_BAD_REQUEST, threaded);
    Wrapper wrapper =
        Tomcat.addServlet(ctx, "asyncErrorServlet", asyncErrorServlet);
    wrapper.setAsyncSupported(true);
    ctx.addServletMapping("/asyncErrorServlet", "asyncErrorServlet");

    if (customError) {
        CustomErrorServlet customErrorServlet = new CustomErrorServlet();
        Tomcat.addServlet(ctx, "customErrorServlet", customErrorServlet);
        ctx.addServletMapping("/customErrorServlet", "customErrorServlet");

        ErrorPage ep = new ErrorPage();
        ep.setLocation("/customErrorServlet");

        ctx.addErrorPage(ep);
    }

    TesterAccessLogValve alv = new TesterAccessLogValve();
    ctx.getPipeline().addValve(alv);

    tomcat.start();

    StringBuilder url = new StringBuilder(48);
    url.append("http://localhost:");
    url.append(getPort());
    url.append("/asyncErrorServlet");

    ByteChunk res = new ByteChunk();
    int rc = getUrl(url.toString(), res, null);

    assertEquals(HttpServletResponse.SC_BAD_REQUEST, rc);

    // SRV 10.9.2 - Handling an error is entirely the application's
    // responsibility when an error occurs on an application thread.
    // Calling sendError() followed by complete() and expecting the standard
    // error page mechanism to kick in could be viewed as handling the error
    String responseBody = res.toString();
    Assert.assertNotNull(responseBody);
    assertTrue(responseBody.length() > 0);
    if (customError) {
        assertTrue(responseBody, responseBody.contains(CustomErrorServlet.ERROR_MESSAGE));
    } else {
        assertTrue(responseBody, responseBody.contains(AsyncErrorServlet.ERROR_MESSAGE));
    }

    // Without this test may complete before access log has a chance to log
    // the request
    Thread.sleep(REQUEST_TIME);

    // Check the access log
    alv.validateAccessLog(1, HttpServletResponse.SC_BAD_REQUEST, 0,
            REQUEST_TIME);
}
 
Example #11
Source File: TesterContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public void addErrorPage(ErrorPage errorPage) {
    // NO-OP
}
 
Example #12
Source File: TesterContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public ErrorPage findErrorPage(int errorCode) {
    return null;
}
 
Example #13
Source File: TesterContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public ErrorPage findErrorPage(String exceptionType) {
    return null;
}
 
Example #14
Source File: TestStandardContextValve.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Test
public void testBug51653b() throws Exception {
    // Set up a container
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    // Traces order of events across multiple components
    StringBuilder trace = new StringBuilder();

    // Add the page that generates the error
    Tomcat.addServlet(ctx, "test", new Bug51653ErrorTrigger());
    ctx.addServletMapping("/test", "test");

    // Add the error page
    Tomcat.addServlet(ctx, "errorPage", new Bug51653ErrorPage(trace));
    ctx.addServletMapping("/error", "errorPage");
    // And the handling for 404 responses
    ErrorPage errorPage = new ErrorPage();
    errorPage.setErrorCode(Response.SC_NOT_FOUND);
    errorPage.setLocation("/error");
    ctx.addErrorPage(errorPage);

    // Add the request listener
    Bug51653RequestListener reqListener =
        new Bug51653RequestListener(trace);
    ((StandardContext) ctx).addApplicationEventListener(reqListener);

    tomcat.start();

    // Request a page that does not exist
    int rc = getUrl("http://localhost:" + getPort() + "/test",
            new ByteChunk(), null);

    // Need to allow time (but not too long in case the test fails) for
    // ServletRequestListener to complete
    int i = 20;
    while (i > 0) {
        if (trace.toString().endsWith("Destroy")) {
            break;
        }
        Thread.sleep(250);
        i--;
    }

    assertEquals(Response.SC_NOT_FOUND, rc);
    assertEquals("InitErrorDestroy", trace.toString());
}
 
Example #15
Source File: TestStandardContextValve.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Test
public void testBug51653a() throws Exception {
    // Set up a container
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    // Traces order of events across multiple components
    StringBuilder trace = new StringBuilder();

    //Add the error page
    Tomcat.addServlet(ctx, "errorPage", new Bug51653ErrorPage(trace));
    ctx.addServletMapping("/error", "errorPage");
    // And the handling for 404 responses
    ErrorPage errorPage = new ErrorPage();
    errorPage.setErrorCode(Response.SC_NOT_FOUND);
    errorPage.setLocation("/error");
    ctx.addErrorPage(errorPage);

    // Add the request listener
    Bug51653RequestListener reqListener =
        new Bug51653RequestListener(trace);
    ((StandardContext) ctx).addApplicationEventListener(reqListener);

    tomcat.start();

    // Request a page that does not exist
    int rc = getUrl("http://localhost:" + getPort() + "/invalid",
            new ByteChunk(), null);

    // Need to allow time (but not too long in case the test fails) for
    // ServletRequestListener to complete
    int i = 20;
    while (i > 0) {
        if (trace.toString().endsWith("Destroy")) {
            break;
        }
        Thread.sleep(250);
        i--;
    }

    assertEquals(Response.SC_NOT_FOUND, rc);
    assertEquals("InitErrorDestroy", trace.toString());
}
 
Example #16
Source File: TesterContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public ErrorPage[] findErrorPages() {
    return null;
}
 
Example #17
Source File: TesterContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public void removeErrorPage(ErrorPage errorPage) {
    // NO-OP
}
 
Example #18
Source File: StandardHostValve.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
/**
 * Handle an HTTP status code or Java exception by forwarding control
 * to the location included in the specified errorPage object.  It is
 * assumed that the caller has already recorded any request attributes
 * that are to be forwarded to this page.  Return <code>true</code> if
 * we successfully utilized the specified error page location, or
 * <code>false</code> if the default error report should be rendered.
 *
 * @param request The request being processed
 * @param response The response being generated
 * @param errorPage The errorPage directive we are obeying
 */
private boolean custom(Request request, Response response,
                         ErrorPage errorPage) {

    if (container.getLogger().isDebugEnabled())
        container.getLogger().debug("Processing " + errorPage);

    try {
        // Forward control to the specified location
        ServletContext servletContext =
            request.getContext().getServletContext();
        RequestDispatcher rd =
            servletContext.getRequestDispatcher(errorPage.getLocation());

        if (rd == null) {
            container.getLogger().error(
                sm.getString("standardHostValue.customStatusFailed", errorPage.getLocation()));
            return false;
        }

        if (response.isCommitted()) {
            // Response is committed - including the error page is the
            // best we can do 
            rd.include(request.getRequest(), response.getResponse());
        } else {
            // Reset the response (keeping the real error code and message)
            response.resetBuffer(true);
            response.setContentLength(-1);

            rd.forward(request.getRequest(), response.getResponse());

            // If we forward, the response is suspended again
            response.setSuspended(false);
        }

        // Indicate that we have successfully processed this custom page
        return (true);

    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        // Report our failure to process this custom page
        container.getLogger().error("Exception Processing " + errorPage, t);
        return (false);

    }
}
 
Example #19
Source File: FailedContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public void removeErrorPage(ErrorPage errorPage) { /* NO-OP */ }
 
Example #20
Source File: FailedContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public ErrorPage[] findErrorPages() { return null; }
 
Example #21
Source File: FailedContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public ErrorPage findErrorPage(String exceptionType) { return null; }
 
Example #22
Source File: FailedContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public ErrorPage findErrorPage(int errorCode) { return null; }
 
Example #23
Source File: FailedContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public void addErrorPage(ErrorPage errorPage) { /* NO-OP */ }
 
Example #24
Source File: TestStandardContextValve.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Test
public void testBug51653b() throws Exception {
    // Set up a container
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    // Traces order of events across multiple components
    StringBuilder trace = new StringBuilder();

    // Add the page that generates the error
    Tomcat.addServlet(ctx, "test", new Bug51653ErrorTrigger());
    ctx.addServletMapping("/test", "test");

    // Add the error page
    Tomcat.addServlet(ctx, "errorPage", new Bug51653ErrorPage(trace));
    ctx.addServletMapping("/error", "errorPage");
    // And the handling for 404 responses
    ErrorPage errorPage = new ErrorPage();
    errorPage.setErrorCode(Response.SC_NOT_FOUND);
    errorPage.setLocation("/error");
    ctx.addErrorPage(errorPage);

    // Add the request listener
    Bug51653RequestListener reqListener =
        new Bug51653RequestListener(trace);
    ((StandardContext) ctx).addApplicationEventListener(reqListener);

    tomcat.start();

    // Request a page that does not exist
    int rc = getUrl("http://localhost:" + getPort() + "/test",
            new ByteChunk(), null);

    // Need to allow time (but not too long in case the test fails) for
    // ServletRequestListener to complete
    int i = 20;
    while (i > 0) {
        if (trace.toString().endsWith("Destroy")) {
            break;
        }
        Thread.sleep(250);
        i--;
    }

    assertEquals(Response.SC_NOT_FOUND, rc);
    assertEquals("InitErrorDestroy", trace.toString());
}
 
Example #25
Source File: FailedContext.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public void addErrorPage(ErrorPage errorPage) { /* NO-OP */ }
 
Example #26
Source File: FailedContext.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public ErrorPage findErrorPage(int errorCode) { return null; }
 
Example #27
Source File: FailedContext.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public ErrorPage findErrorPage(String exceptionType) { return null; }
 
Example #28
Source File: FailedContext.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public ErrorPage[] findErrorPages() { return null; }
 
Example #29
Source File: FailedContext.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public void removeErrorPage(ErrorPage errorPage) { /* NO-OP */ }
 
Example #30
Source File: StandardHostValve.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
/**
 * Handle an HTTP status code or Java exception by forwarding control
 * to the location included in the specified errorPage object.  It is
 * assumed that the caller has already recorded any request attributes
 * that are to be forwarded to this page.  Return <code>true</code> if
 * we successfully utilized the specified error page location, or
 * <code>false</code> if the default error report should be rendered.
 *
 * @param request The request being processed
 * @param response The response being generated
 * @param errorPage The errorPage directive we are obeying
 */
private boolean custom(Request request, Response response,
                         ErrorPage errorPage) {

    if (container.getLogger().isDebugEnabled())
        container.getLogger().debug("Processing " + errorPage);

    try {
        // Forward control to the specified location
        ServletContext servletContext =
            request.getContext().getServletContext();
        RequestDispatcher rd =
            servletContext.getRequestDispatcher(errorPage.getLocation());

        if (rd == null) {
            container.getLogger().error(
                sm.getString("standardHostValue.customStatusFailed", errorPage.getLocation()));
            return false;
        }

        if (response.isCommitted()) {
            // Response is committed - including the error page is the
            // best we can do 
            rd.include(request.getRequest(), response.getResponse());
        } else {
            // Reset the response (keeping the real error code and message)
            response.resetBuffer(true);
            response.setContentLength(-1);

            rd.forward(request.getRequest(), response.getResponse());

            // If we forward, the response is suspended again
            response.setSuspended(false);
        }

        // Indicate that we have successfully processed this custom page
        return (true);

    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        // Report our failure to process this custom page
        container.getLogger().error("Exception Processing " + errorPage, t);
        return (false);

    }
}