Created attachment 30152 [details] helloWorld.tagx Steps to reproduce: 1. Go to webapps\examples\WEB-INF\tags\ 2. Delete "helloWorld.tag" file and put there "helloWorld.tagx" file attached to this issue. The file contains the following plus AL header: <?xml version="1.0" encoding="utf-8" ?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"> <jsp:scriptlet><![CDATA[// // ${foo} out.println("Hello, world!!"); ]]></jsp:scriptlet> </jsp:root> 3. Start Tomcat and try to open the following page in a browser: http://localhost:8080/examples/jsp/jsp2/tagfiles/hello.jsp ACTUAL result: in current TC8 trunk: org.xml.sax.SAXException: Body of scriptlet element must not contain any XML elements org.apache.jasper.compiler.JspDocumentParser.checkScriptingBody(JspDocumentParser.java:1332) org.apache.jasper.compiler.JspDocumentParser.endElement(JspDocumentParser.java:650) This behaviour is caused by "${foo}" being present inside the scriptlet. If I remove that line, the page is displayed successfully. EXPECTED RESULT I think EL expressions should not be recognized inside of jsp:scriptlet, jsp:declaration or jsp:expression and should not trigger such an error. As a confirmation, the following "helloWorld.tag" in JSP syntax compiles and executes successfully. Thus this issue is with XML syntax only, <% // ${foo} %> Hello, world!++ Alternative solution could be to change the error message, but I think it is not the issue here, s/ any XML elements / any XML elements or EL expressions/
Created attachment 30153 [details] Stacktrace (current 7.0 = 7.0.39)
Created attachment 30167 [details] 2013-04-10_tc8_54801_1.patch 1. The JSP 2.2 specification chapter JSP.1.11 EL Elements says: "EL expressions can appear in template data and in attribute values." I deduce that they cannot appear in scripting elements and thus trying to parse them there is a bug. Scripting elements are represented in Jasper by abstract Node.ScriptingElement class. Its non-abstract derived classes are: Declaration, Expression, Scriptlet. 2. Parsing of EL here is performed in JspDocumentParser#processChars() I am attaching patch that fixes processing for scripting elements in processChars(). 3. It is strange that processChars() does EL parsing regardless of pageInfo.isELIgnored(). I suspect that it is a bug. The code in the patch is the same as in "if (tagDependentNesting > 0)" block there, so the two could be merged, and be also used to fix the "isELIgnored" case. There are no testcases in the patch yet.
Created attachment 30168 [details] page1.jspx
Created attachment 30169 [details] page2.jspx
> helloWorld.tagx This issue is not specific to tag files and is reproducible with JSP documents as well. I attached "page1.jspx" and "page2.jspx" that reproduce this. I am changing TITLE of this issue accordingly. Presence of "CDATA" block is not important. (In reply to comment #2) > > 3. It is strange that processChars() does EL parsing regardless of > pageInfo.isELIgnored(). I suspect that it is a bug. > Confirmed as a bug. I filed it separately as bug 54821.
Fixed in trunk and will be included in 7.0.40 onwards. I turned the example JSP documents into unit tests.