Author: markt Date: Fri Jan 26 19:25:23 2018 New Revision: 1822339 URL: http://svn.apache.org/viewvc?rev=1822339&view=rev Log: Improve OPTION and Allow behavior for JSPs.
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Generator.java tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/jasper/compiler/Generator.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Generator.java?rev=1822339&r1=1822338&r2=1822339&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/Generator.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/Generator.java Fri Jan 26 19:25:23 2018 @@ -772,15 +772,25 @@ class Generator { // Method check if (!pageInfo.isErrorPage()) { + out.printil("if (!javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {"); + out.pushIndent(); out.printil("final java.lang.String _jspx_method = request.getMethod();"); - out.printin("if (!\"GET\".equals(_jspx_method) && !\"POST\".equals(_jspx_method) && !\"HEAD\".equals(_jspx_method) && "); - out.println("!javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {"); + out.printil("if (\"OPTIONS\".equals(_jspx_method)) {"); out.pushIndent(); + out.printil("response.setHeader(\"Allow\",\"GET, HEAD, POST, OPTIONS\");"); + out.printil("return;"); + out.popIndent(); + out.printil("}"); + out.printil("if (!\"GET\".equals(_jspx_method) && !\"POST\".equals(_jspx_method) && !\"HEAD\".equals(_jspx_method)) {"); + out.pushIndent(); + out.printil("response.setHeader(\"Allow\",\"GET, HEAD, POST, OPTIONS\");"); out.printin("response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "); out.println("\"" + Localizer.getMessage("jsp.error.servlet.invalid.method") + "\");"); out.printil("return;"); out.popIndent(); out.printil("}"); + out.popIndent(); + out.printil("}"); out.println(); } Modified: tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties?rev=1822339&r1=1822338&r2=1822339&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties Fri Jan 26 19:25:23 2018 @@ -379,7 +379,7 @@ jsp.error.page.conflict.trimdirectivewhi jsp.error.tag.conflict.trimdirectivewhitespaces=Tag directive: illegal to have multiple occurrences of ''trimDirectiveWhitespaces'' with different values (old: [{0}], new: [{1}]) # JSP Servlet -jsp.error.servlet.invalid.method=JSPs only permit GET POST or HEAD +jsp.error.servlet.invalid.method=JSPs only permit GET, POST or HEAD. Jasper also permits OPTIONS jsp.error.servlet.destroy.failed=Exception during Servlet.destroy() for JSP page # JarScanner Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1822339&r1=1822338&r2=1822339&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Fri Jan 26 19:25:23 2018 @@ -95,6 +95,20 @@ </fix> </changelog> </subsection> + <subsection name="Jasper"> + <changelog> + <fix> + Include an HTTP <code>Allow</code> header when a JSP generates a + 405 reponse due to a request with an unsupported method. (markt) + </fix> + <add> + Add support for the HTTP <code>OPTION</code> method to JSPs. The + JSP specification explicitly states that the behaviour for this + method is undefined for JSPs so this is a Tomcat specific + behaviour. (markt) + </add> + </changelog> + </subsection> </section> <section name="Tomcat 9.0.4 (markt)" rtext="2018-01-22"> <subsection name="Catalina"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org