-
Bug
-
Resolution: Done
-
Major
-
7.1.4.GA
-
None
JSP "optimize-scriplets" causes compilation failure when string concatenation exists inside method arguments.
For example, when optimize-scriplets="true" is enabled in undertow subsystem and a JSP has the following expression:
<img src='<%=response.encodeURL(request.getContextPath() + "/image/test.jpg")%>'/>
the JSP request fails due to compile error with the following log message:
ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /test/example.jsp: org.apache.jasper.JasperException: JBWEB004062: Unable to compile class for JSP: JBWEB004060: An error occurred at line: 1 in the jsp file: /example.jsp The method print(String) in the type JspWriter is not applicable for the arguments (String, void) 1: <img src='<%=response.encodeURL(request.getContextPath() + "/image/test.jpg")%>'/> JBWEB004060: An error occurred at line: 1 in the jsp file: /example.jsp Syntax error on token ";", , expected 1: <img src='<%=response.encodeURL(request.getContextPath() + "/image/test.jpg")%>'/> Stacktrace: at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:95) at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:198) at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:455) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:359) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:334) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:321) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:652) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ...
When "optimize-scriplets" is enabled, the java code is generated like the following. The compilation failure happens because "out.print()" has the wrong method signature:
out.write("<img src='"); out.print(response.encodeURL(request.getContextPath() ); out.print("/image/test.jpg")); out.write("'/>\n");
When "optimize-scriplets" is not enabled, the java code is generated like:
out.write("<img src='"); out.print(response.encodeURL(request.getContextPath() + "/image/test.jpg")); out.write("'/>\n");
- clones
-
JBEAP-15746 [GSS](7.2.z) UNDERTOW-1429 - JSP optimize-scriplets causes compilation failure when string concatenation exists inside method arguments
- Closed
- is incorporated by
-
JBEAP-15747 [GSS](7.1.z) Upgrade jastow from 2.0.6.Final-redhat-00001 to 2.0.7.Final
- Closed
- is related to
-
UNDERTOW-1429 optimize-scriplets causes compile error when strings are concatenated in method calls
- Pull Request Sent
- links to