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
The following commit(s) were added to refs/heads/main by this push: new 41258a7455 Update ErrorData for new error dispatch attribute 41258a7455 is described below commit 41258a7455291e5eb6e0ffefcb5cfffcbbd29b37 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Nov 18 17:36:24 2022 +0000 Update ErrorData for new error dispatch attribute --- java/jakarta/servlet/jsp/ErrorData.java | 35 +++++++++++++++++++++++++++++++ java/jakarta/servlet/jsp/PageContext.java | 10 ++++----- webapps/docs/changelog.xml | 6 ++++++ 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/java/jakarta/servlet/jsp/ErrorData.java b/java/jakarta/servlet/jsp/ErrorData.java index 7ab0f12b67..ca7d610522 100644 --- a/java/jakarta/servlet/jsp/ErrorData.java +++ b/java/jakarta/servlet/jsp/ErrorData.java @@ -31,6 +31,7 @@ public final class ErrorData { private final int statusCode; private final String uri; private final String servletName; + private final String queryString; /** * Creates a new ErrorData object. @@ -43,13 +44,37 @@ public final class ErrorData { * The request URI * @param servletName * The name of the servlet invoked + * + * @deprecated Use {#link {@link ErrorData#ErrorData(Throwable, int, String, + * String, String)} */ + @Deprecated(since = "4.0", forRemoval = true) public ErrorData(Throwable throwable, int statusCode, String uri, String servletName) { + this(throwable, statusCode, uri, servletName, null); + } + + /** + * Creates a new ErrorData object. + * + * @param throwable + * The Throwable that is the cause of the error + * @param statusCode + * The status code of the error + * @param uri + * The request URI + * @param servletName + * The name of the servlet invoked + * @param queryString + * The request query string + */ + public ErrorData(Throwable throwable, int statusCode, String uri, + String servletName, String queryString) { this.throwable = throwable; this.statusCode = statusCode; this.uri = uri; this.servletName = servletName; + this.queryString = queryString; } /** @@ -87,4 +112,14 @@ public final class ErrorData { public String getServletName() { return this.servletName; } + + /** + * Returns the request query string or {@code null} if the request had no + * query string. + * + * @return The request query string + */ + public String getQueryString() { + return this.queryString; + } } diff --git a/java/jakarta/servlet/jsp/PageContext.java b/java/jakarta/servlet/jsp/PageContext.java index 391aa3372f..806721f333 100644 --- a/java/jakarta/servlet/jsp/PageContext.java +++ b/java/jakarta/servlet/jsp/PageContext.java @@ -521,13 +521,11 @@ public abstract class PageContext } return new ErrorData( - (Throwable)getRequest().getAttribute( - RequestDispatcher.ERROR_EXCEPTION), + (Throwable)getRequest().getAttribute(RequestDispatcher.ERROR_EXCEPTION), status, - (String)getRequest().getAttribute( - RequestDispatcher.ERROR_REQUEST_URI), - (String)getRequest().getAttribute( - RequestDispatcher.ERROR_SERVLET_NAME) + (String)getRequest().getAttribute(RequestDispatcher.ERROR_REQUEST_URI), + (String)getRequest().getAttribute(RequestDispatcher.ERROR_SERVLET_NAME), + (String)getRequest().getAttribute(RequestDispatcher.ERROR_QUERY_STRING) ); } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 7a64f324c3..cf0c9c7f4d 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -219,6 +219,12 @@ <bug>66325</bug>: Fix concurrency issue in evaluation of expression language containing lambda expressions. (markt) </fix> + <add> + Update the <code>ErrorData</code> class in the JSP API to align with the + recent changes in the Jakarta Pages specification to support the new + error dispatch attribute + <code>jakarta.servlet.error.query_string</code>. + </add> </changelog> </subsection> <subsection name="Other"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org