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/18 20:00:00 UTC

[tomcat] branch master updated: Remove redundant sole path/URI from error page message on SC_NOT_FOUND

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 bde69a2  Remove redundant sole path/URI from error page message on SC_NOT_FOUND
bde69a2 is described below

commit bde69a2808daf1804f8816ddacbdd8e93f245da2
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sat Apr 18 20:58:40 2020 +0200

    Remove redundant sole path/URI from error page message on SC_NOT_FOUND
    
    When a component issues a SC_NOT_FOUND don't respond with the path/URI only in
    the error message because it does not offer any more detail about the error,
    plus the client knows the path/URI already.
---
 java/org/apache/catalina/servlets/DefaultServlet.java |  5 ++---
 java/org/apache/catalina/servlets/WebdavServlet.java  |  2 +-
 java/org/apache/catalina/ssi/SSIServlet.java          |  6 +++---
 java/org/apache/jasper/servlet/JspServlet.java        |  3 +--
 webapps/docs/changelog.xml                            | 11 +++++++++++
 5 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java b/java/org/apache/catalina/servlets/DefaultServlet.java
index 06794ac..5ee7724 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -850,7 +850,7 @@ public class DefaultServlet extends HttpServlet {
                 response.sendError(((Integer) request.getAttribute(
                         RequestDispatcher.ERROR_STATUS_CODE)).intValue());
             } else {
-                response.sendError(HttpServletResponse.SC_NOT_FOUND, requestUri);
+                response.sendError(HttpServletResponse.SC_NOT_FOUND);
             }
             return;
         }
@@ -939,8 +939,7 @@ public class DefaultServlet extends HttpServlet {
             // Skip directory listings if we have been configured to
             // suppress them
             if (!listings) {
-                response.sendError(HttpServletResponse.SC_NOT_FOUND,
-                                   request.getRequestURI());
+                response.sendError(HttpServletResponse.SC_NOT_FOUND);
                 return;
             }
             contentType = "text/html;charset=UTF-8";
diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java b/java/org/apache/catalina/servlets/WebdavServlet.java
index dd2107d..683437c 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -623,7 +623,7 @@ public class WebdavServlet extends DefaultServlet {
         }
 
         if (!resource.exists()) {
-            resp.sendError(HttpServletResponse.SC_NOT_FOUND, path);
+            resp.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
 
diff --git a/java/org/apache/catalina/ssi/SSIServlet.java b/java/org/apache/catalina/ssi/SSIServlet.java
index 296c2fb..1648052 100644
--- a/java/org/apache/catalina/ssi/SSIServlet.java
+++ b/java/org/apache/catalina/ssi/SSIServlet.java
@@ -157,12 +157,12 @@ public class SSIServlet extends HttpServlet {
         // (the "toUpperCase()" avoids problems on Windows systems)
         if (path == null || path.toUpperCase(Locale.ENGLISH).startsWith("/WEB-INF")
                 || path.toUpperCase(Locale.ENGLISH).startsWith("/META-INF")) {
-            res.sendError(HttpServletResponse.SC_NOT_FOUND, path);
+            res.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
         URL resource = servletContext.getResource(path);
         if (resource == null) {
-            res.sendError(HttpServletResponse.SC_NOT_FOUND, path);
+            res.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
         String resourceMimeType = servletContext.getMimeType(path);
@@ -221,4 +221,4 @@ public class SSIServlet extends HttpServlet {
         }
         bufferedReader.close();
     }
-}
\ No newline at end of file
+}
diff --git a/java/org/apache/jasper/servlet/JspServlet.java b/java/org/apache/jasper/servlet/JspServlet.java
index 1ee0630..2e13ccc 100644
--- a/java/org/apache/jasper/servlet/JspServlet.java
+++ b/java/org/apache/jasper/servlet/JspServlet.java
@@ -408,8 +408,7 @@ public class JspServlet extends HttpServlet implements PeriodicEventListener {
             throw new ServletException(Escape.htmlElementContent(msg));
         } else {
             try {
-                response.sendError(HttpServletResponse.SC_NOT_FOUND,
-                        request.getRequestURI());
+                response.sendError(HttpServletResponse.SC_NOT_FOUND);
             } catch (IllegalStateException ise) {
                 log.error(Localizer.getMessage("jsp.error.file.not.found",
                         jspUri));
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 930a1bd..bae248f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -71,6 +71,10 @@
         that use a custom class loader that loads resources from non-standard
         locations. (markt)
       </fix>
+      <update>
+        Remove redundant sole path/URI from error page message on SC_NOT_FOUND.
+        (michaelo)
+      </update>
     </changelog>
   </subsection>
   <subsection name="Coyote">
@@ -85,6 +89,13 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="Jasper">
+    <changelog>
+      <update>
+        Remove redundant sole path/URI from error page message on SC_NOT_FOUND.
+        (michaelo)
+    </changelog>
+  </subsection>
   <subsection name="Other">
     <changelog>
       <update>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org