From cdfffc1525febb20ab3f0bd281890fee80c2a4c3 Mon Sep 17 00:00:00 2001 From: markt Date: Mon, 8 Mar 2010 18:58:28 +0000 Subject: [PATCH] Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48661 If the response has been committed, include the error page like Jasper does git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@920449 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/catalina/core/StandardHostValve.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/java/org/apache/catalina/core/StandardHostValve.java b/java/org/apache/catalina/core/StandardHostValve.java index c853705a8..6ebf5d45b 100644 --- a/java/org/apache/catalina/core/StandardHostValve.java +++ b/java/org/apache/catalina/core/StandardHostValve.java @@ -416,18 +416,25 @@ final class StandardHostValve request.setPathInfo(errorPage.getLocation()); try { - // Reset the response (keeping the real error code and message) - response.resetBuffer(true); - // Forward control to the specified location ServletContext servletContext = request.getContext().getServletContext(); RequestDispatcher rd = servletContext.getRequestDispatcher(errorPage.getLocation()); - rd.forward(request.getRequest(), response.getResponse()); - // If we forward, the response is suspended again - response.setSuspended(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); + + 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); -- 2.11.0