You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mi...@apache.org on 2020/04/21 14:05:59 UTC
[tomcat] branch 9.0.x updated: Add more descriptive error messages
in DefaultServlet/JspServlet for SC_NOT_FOUND
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 564434d Add more descriptive error messages in DefaultServlet/JspServlet for SC_NOT_FOUND
564434d is described below
commit 564434dff163832149ceebb02ee9a20bdf889a7c
Author: Michael Osipov <mi...@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 a7968b1..ebb622a 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -850,7 +850,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;
}
@@ -939,7 +940,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 2443f05..392b0e2 100644
--- a/java/org/apache/jasper/resources/LocalStrings.properties
+++ b/java/org/apache/jasper/resources/LocalStrings.properties
@@ -74,7 +74,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 591e5e9..bc7f582 100644
--- a/java/org/apache/jasper/resources/LocalStrings_de.properties
+++ b/java/org/apache/jasper/resources/LocalStrings_de.properties
@@ -28,7 +28,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.internal.unexpectedNodeType=Unerwarteter Knotentyp
jsp.error.invalid.attribute=[{0}] hat ein ungültiges Attribut: [{1}]
diff --git a/java/org/apache/jasper/servlet/JspServlet.java b/java/org/apache/jasper/servlet/JspServlet.java
index db93257..ae9788b 100644
--- a/java/org/apache/jasper/servlet/JspServlet.java
+++ b/java/org/apache/jasper/servlet/JspServlet.java
@@ -397,20 +397,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);
}
}
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 4f884b8..f27be5a 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -67,6 +67,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">
@@ -87,6 +91,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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org