From cb18f0c9c61890c1583c64ed5533afeb506fd6bc Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Thu, 23 Nov 2023 18:28:56 +0000 Subject: [PATCH] Update ErrorData to include new method attribute --- .../java/jakarta/servlet/jsp/ErrorData.java | 19 ++++++++++++++++--- .../java/jakarta/servlet/jsp/PageContext.java | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/api/src/main/java/jakarta/servlet/jsp/ErrorData.java b/api/src/main/java/jakarta/servlet/jsp/ErrorData.java index 14a9ff6b..42954092 100644 --- a/api/src/main/java/jakarta/servlet/jsp/ErrorData.java +++ b/api/src/main/java/jakarta/servlet/jsp/ErrorData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020 Oracle and/or its affiliates and others. + * Copyright (c) 1997, 2023 Oracle and/or its affiliates and others. * All rights reserved. * Copyright 2004 The Apache Software Foundation * @@ -30,6 +30,7 @@ public final class ErrorData { private final Throwable throwable; private final int statusCode; + private final String method; private final String uri; private final String queryString; private final String servletName; @@ -46,7 +47,7 @@ public final class ErrorData { */ @Deprecated(since = "4.0", forRemoval = true) public ErrorData(Throwable throwable, int statusCode, String uri, String servletName) { - this(throwable, statusCode, uri, servletName, null); + this(throwable, statusCode, null, uri, servletName, null); } /** @@ -54,13 +55,16 @@ public ErrorData(Throwable throwable, int statusCode, String uri, String servlet * * @param throwable The Throwable that is the cause of the error * @param statusCode The status code of the error + * @param method The request method * @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) { + public ErrorData(Throwable throwable, int statusCode, String method, String uri, String servletName, + String queryString) { this.throwable = throwable; this.statusCode = statusCode; + this.method = method; this.uri = uri; this.servletName = servletName; this.queryString = queryString; @@ -84,6 +88,15 @@ public int getStatusCode() { return this.statusCode; } + /** + * Returns the request method. + * + * @return The request method + */ + public String getMethod() { + return this.method; + } + /** * Returns the request URI. * diff --git a/api/src/main/java/jakarta/servlet/jsp/PageContext.java b/api/src/main/java/jakarta/servlet/jsp/PageContext.java index 2457cda1..d71877f3 100644 --- a/api/src/main/java/jakarta/servlet/jsp/PageContext.java +++ b/api/src/main/java/jakarta/servlet/jsp/PageContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020 Oracle and/or its affiliates and others. + * Copyright (c) 1997, 2023 Oracle and/or its affiliates and others. * All rights reserved. * Copyright 2004 The Apache Software Foundation * @@ -423,9 +423,9 @@ public BodyContent pushBody() { public ErrorData getErrorData() { return new ErrorData((Throwable) getRequest().getAttribute("jakarta.servlet.error.exception"), ((Integer) getRequest().getAttribute("jakarta.servlet.error.status_code")).intValue(), + (String) getRequest().getAttribute("jakarta.servlet.error.method"), (String) getRequest().getAttribute("jakarta.servlet.error.request_uri"), (String) getRequest().getAttribute("jakarta.servlet.error.servlet_name"), (String) getRequest().getAttribute("jakarta.servlet.error.query_string")); } - }