This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new ddcc3dd Add more descriptive error messages in
DefaultServlet/JspServlet for SC_NOT_FOUND
ddcc3dd is described below
commit ddcc3ddabe7deddf84cd2d83e2a645b17becc66e
Author: Michael Osipov <[email protected]>
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 d0bb994..fe43c53 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 dedb9cb..d2f303c 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 2e13ccc..ab572b1 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);
}
}
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 9f5f0e5..25f0aee 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -82,6 +82,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">
@@ -102,6 +106,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: [email protected]
For additional commands, e-mail: [email protected]