This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit c3e7054284aafd054e86f9ceccb19c9dd7aac69a Author: Mark Thomas <[email protected]> AuthorDate: Fri Nov 18 16:15:11 2022 +0000 Add support for jakarta.servlet.error.query_string on error dispatches --- java/jakarta/servlet/RequestDispatcher.java | 8 ++++++++ java/org/apache/catalina/core/StandardHostValve.java | 2 ++ webapps/docs/changelog.xml | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/java/jakarta/servlet/RequestDispatcher.java b/java/jakarta/servlet/RequestDispatcher.java index 0c94b00921..190d3099fb 100644 --- a/java/jakarta/servlet/RequestDispatcher.java +++ b/java/jakarta/servlet/RequestDispatcher.java @@ -213,6 +213,14 @@ public interface RequestDispatcher { */ public static final String ERROR_REQUEST_URI = "jakarta.servlet.error.request_uri"; + /** + * The name of the request attribute under which the query string for request whose processing caused the error is + * propagated during an error dispatch + * + * @since Servlet 6.1 + */ + static final String ERROR_QUERY_STRING = "jakarta.servlet.error.query_string"; + /** * The name of the request attribute that should be set by the container * when custom error-handling servlet or JSP page is invoked. The value of diff --git a/java/org/apache/catalina/core/StandardHostValve.java b/java/org/apache/catalina/core/StandardHostValve.java index 75ae889a95..8e0c5b283f 100644 --- a/java/org/apache/catalina/core/StandardHostValve.java +++ b/java/org/apache/catalina/core/StandardHostValve.java @@ -225,6 +225,7 @@ final class StandardHostValve extends ValveBase { request.setAttribute(RequestDispatcher.ERROR_SERVLET_NAME, wrapper.getName()); } request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI, request.getRequestURI()); + request.setAttribute(RequestDispatcher.ERROR_QUERY_STRING, request.getQueryString()); if (custom(request, response, errorPage)) { response.setErrorReported(); try { @@ -292,6 +293,7 @@ final class StandardHostValve extends ValveBase { request.setAttribute(RequestDispatcher.ERROR_SERVLET_NAME, wrapper.getName()); } request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI, request.getRequestURI()); + request.setAttribute(RequestDispatcher.ERROR_QUERY_STRING, request.getQueryString()); request.setAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE, realError.getClass()); if (custom(request, response, errorPage)) { try { diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 7f4ec93b79..7a64f324c3 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -162,6 +162,10 @@ the Servlet context so that it actually reflects what is used during authentication. (remm) </fix> + <add> + Add support for the new attribute for error dispatches + <code>jakarta.servlet.error.query_string</code>. (markt) + </add> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
