--- java/org/apache/catalina/servlets/DefaultServlet.java.orig 2017-06-09 13:23:44.198085912 -0400 +++ java/org/apache/catalina/servlets/DefaultServlet.java 2017-06-09 13:23:44.209085950 -0400 @@ -245,7 +245,7 @@ urlEncoder.addSafeCharacter('.'); urlEncoder.addSafeCharacter('*'); urlEncoder.addSafeCharacter('/'); - + if (Globals.IS_SECURITY_ENABLED) { factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); @@ -423,6 +423,18 @@ } + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + if (req.getDispatcherType() == DispatcherType.ERROR) { + doGet(req, resp); + } else { + super.service(req, resp); + } + } + + /** * Process a GET request for the specified resource. * @@ -860,8 +872,7 @@ } } - boolean isError = - response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST; + boolean isError = DispatcherType.ERROR == request.getDispatcherType(); // Check if the conditions specified in the optional If headers are // satisfied. @@ -1326,7 +1337,7 @@ } - + /** * Return an InputStream to an HTML representation of the contents * of this directory. @@ -1767,15 +1778,15 @@ private File validateGlobalXsltFile() { - + File result = null; String base = System.getProperty(Globals.CATALINA_BASE_PROP); - + if (base != null) { File baseConf = new File(base, "conf"); result = validateGlobalXsltFile(baseConf); } - + if (result == null) { String home = System.getProperty(Globals.CATALINA_HOME_PROP); if (home != null && !home.equals(base)) { @@ -2364,6 +2375,8 @@ /** * Validate range. + * + * @return true if the range is valid, otherwise false */ public boolean validate() { if (end >= length) --- java/org/apache/catalina/servlets/WebdavServlet.java.orig 2017-06-09 13:23:44.199085915 -0400 +++ java/org/apache/catalina/servlets/WebdavServlet.java 2017-06-09 13:23:44.208085946 -0400 @@ -40,6 +40,7 @@ import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.directory.DirContext; +import javax.servlet.DispatcherType; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; @@ -353,6 +354,11 @@ return; } + if (req.getDispatcherType() == DispatcherType.ERROR) { + doGet(req, resp); + return; + } + final String method = req.getMethod(); if (debug > 0) { --- webapps/docs/changelog.xml.orig 2017-06-09 13:23:44.201085922 -0400 +++ webapps/docs/changelog.xml 2017-06-09 13:25:14.586400695 -0400 @@ -64,6 +64,17 @@ Ensure request and response facades are used when firing application listeners. (markt/remm) + + Use a more reliable mechanism for the DefaultServlet when + determining if the current request is for custom error page or not. + (markt) + + + Ensure that when the Default or WebDAV servlets process an error + dispatch that the error resource is processed via the + doGet() method irrespective of the method used for the + original request that triggered the error. (markt) +