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:57 UTC
[tomcat] branch 7.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 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push:
new f73fe83 Add more descriptive error messages in DefaultServlet/JspServlet for SC_NOT_FOUND
f73fe83 is described below
commit f73fe83ee417106531e008ca924dec04e9ce3e29
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 a959844..fa2806c 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -849,7 +849,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;
}
@@ -885,7 +886,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 df88df1..1220274 100644
--- a/java/org/apache/jasper/resources/LocalStrings.properties
+++ b/java/org/apache/jasper/resources/LocalStrings.properties
@@ -69,7 +69,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.file.not.registered=file [{0}] not seen in include
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}'
diff --git a/java/org/apache/jasper/resources/LocalStrings_de.properties b/java/org/apache/jasper/resources/LocalStrings_de.properties
index d6891ca..44a1c29 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 0db97ed..13e2979 100644
--- a/java/org/apache/jasper/servlet/JspServlet.java
+++ b/java/org/apache/jasper/servlet/JspServlet.java
@@ -407,20 +407,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(SecurityUtil.filter(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 2d98d99..9bed6ec 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -89,6 +89,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>
<subsection name="Coyote">
@@ -130,6 +134,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>
<subsection name="Cluster">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org