Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-15746

[GSS](7.2.z) UNDERTOW-1429 - JSP optimize-scriplets causes compilation failure when string concatenation exists inside method arguments

    XMLWordPrintable

Details

    • Hide

      1. Start EAP and enable optimize scriptlets for JSPs

      /subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=optimize-scriptlets, value=true)
      

      2. Deploy a web app which contains a simple JSP file having the following expression:

      <%=response.encodeURL(request.getContextPath() + "/image/test.jpg")%>
      

      3. Access the JSP with curl command

      Show
      1. Start EAP and enable optimize scriptlets for JSPs /subsystem=undertow/servlet-container= default /setting=jsp:write-attribute(name=optimize-scriptlets, value= true ) 2. Deploy a web app which contains a simple JSP file having the following expression: <%=response.encodeURL(request.getContextPath() + "/image/test.jpg" )%> 3. Access the JSP with curl command

    Description

      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");
      

      Attachments

        Issue Links

          Activity

            People

              johara@redhat.com John O&#39;Hara
              rhn-support-mmiura Masafumi Miura
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: