This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new 70544d1 Add more descriptive error messages in DefaultServlet/JspServlet for SC_NOT_FOUND 70544d1 is described below commit 70544d11b0b96b8fe8a5e09cb5df86015ee3cb40 Author: Michael Osipov <micha...@apache.org> AuthorDate: Tue Apr 21 15:49:59 2020 +0200 Add more descriptive error messages in DefaultServlet/JspServlet for SC_NOT_FOUND --- java/org/apache/catalina/servlets/DefaultServlet.java | 6 ++++-- java/org/apache/jasper/resources/LocalStrings.properties | 2 +- java/org/apache/jasper/resources/LocalStrings_de.properties | 2 +- java/org/apache/jasper/servlet/JspServlet.java | 8 +++----- webapps/docs/changelog.xml | 8 ++++++++ 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java b/java/org/apache/catalina/servlets/DefaultServlet.java index cacf06c..2e7bc46 100644 --- a/java/org/apache/catalina/servlets/DefaultServlet.java +++ b/java/org/apache/catalina/servlets/DefaultServlet.java @@ -857,7 +857,8 @@ public class DefaultServlet extends HttpServlet { response.sendError(((Integer) request.getAttribute( RequestDispatcher.ERROR_STATUS_CODE)).intValue()); } else { - response.sendError(HttpServletResponse.SC_NOT_FOUND); + response.sendError(HttpServletResponse.SC_NOT_FOUND, + sm.getString("defaultServlet.missingResource", requestUri)); } return; } @@ -946,7 +947,8 @@ public class DefaultServlet extends HttpServlet { // Skip directory listings if we have been configured to // suppress them if (!listings) { - response.sendError(HttpServletResponse.SC_NOT_FOUND); + response.sendError(HttpServletResponse.SC_NOT_FOUND, + sm.getString("defaultServlet.missingResource", request.getRequestURI())); return; } contentType = "text/html;charset=UTF-8"; diff --git a/java/org/apache/jasper/resources/LocalStrings.properties b/java/org/apache/jasper/resources/LocalStrings.properties index 0736ae9..edd2477 100644 --- a/java/org/apache/jasper/resources/LocalStrings.properties +++ b/java/org/apache/jasper/resources/LocalStrings.properties @@ -68,7 +68,7 @@ jsp.error.el_interpreter_class.instantiation=Failed to load or instantiate ELInt jsp.error.fallback.invalidUse=jsp:fallback must be a direct child of jsp:plugin jsp.error.file.already.registered=Recursive include of file [{0}] jsp.error.file.cannot.read=Cannot read file: [{0}] -jsp.error.file.not.found=File [{0}] not found +jsp.error.file.not.found=JSP file [{0}] not found jsp.error.flush=Exception occurred when flushing data jsp.error.fragmentwithtype=Cannot specify both 'fragment' and 'type' attributes. If 'fragment' is present, 'type' is fixed as '{0}' jsp.error.function.classnotfound=The class [{0}] specified in TLD for the function [{1}] cannot be found: [{2}] diff --git a/java/org/apache/jasper/resources/LocalStrings_de.properties b/java/org/apache/jasper/resources/LocalStrings_de.properties index 826a08b..561324d 100644 --- a/java/org/apache/jasper/resources/LocalStrings_de.properties +++ b/java/org/apache/jasper/resources/LocalStrings_de.properties @@ -24,7 +24,7 @@ jsp.error.compiler=Keine Java-Compiler verfügbar jsp.error.data.file.processing=Fehler beim Verarbeiten der Datei [{0}] jsp.error.el.template.deferred=#{...} is im Template Text nicht erlaubt jsp.error.fallback.invalidUse=jsp:fallback muss ein direktes Kind von jsp:plugin sein -jsp.error.file.not.found=Datei [{0}] nicht gefunden +jsp.error.file.not.found=JSP-Datei [{0}] nicht gefunden jsp.error.internal.filenotfound=Interner Fehler: Datei [{0}] nicht gefunden jsp.error.invalid.attribute=[{0}] hat ein ungültiges Attribut: [{1}] jsp.error.invalid.tagdir=Tag Verzeichnis [{0}] beginnt nicht mit "/WEB-INF/tags" diff --git a/java/org/apache/jasper/servlet/JspServlet.java b/java/org/apache/jasper/servlet/JspServlet.java index 3407aef..ab419d7 100644 --- a/java/org/apache/jasper/servlet/JspServlet.java +++ b/java/org/apache/jasper/servlet/JspServlet.java @@ -398,20 +398,18 @@ public class JspServlet extends HttpServlet implements PeriodicEventListener { String includeRequestUri = (String)request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI); + String msg = Localizer.getMessage("jsp.error.file.not.found",jspUri); if (includeRequestUri != null) { // This file was included. Throw an exception as // a response.sendError() will be ignored - String msg = - Localizer.getMessage("jsp.error.file.not.found",jspUri); // Strictly, filtering this is an application // responsibility but just in case... throw new ServletException(Escape.htmlElementContent(msg)); } else { try { - response.sendError(HttpServletResponse.SC_NOT_FOUND); + response.sendError(HttpServletResponse.SC_NOT_FOUND, msg); } catch (IllegalStateException ise) { - log.error(Localizer.getMessage("jsp.error.file.not.found", - jspUri)); + log.error(msg); } } return; diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index a36aebc..4a29e3f 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -69,6 +69,10 @@ <code>CredentialHandler</code> and it is likely that a configuration error has occurred. (markt) </add> + <add> + Add more descriptive error message in DefaultServlet for SC_NOT_FOUND. + (michaelo) + </add> </changelog> </subsection> <subsection name="Coyote"> @@ -89,6 +93,10 @@ Remove redundant sole path/URI from error page message on SC_NOT_FOUND. (michaelo) </update> + <add> + Add more descriptive error message in DefaultServlet for SC_NOT_FOUND. + (michaelo) + </add> </changelog> </subsection> <subseciton name="Web applications"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org