The following JSPX file worked upto Tomcat 7.0.47: <?xml version="1.0" encoding="UTF-8"?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" > <jsp:directive.page contentType="text/html; charset=utf-8" pageEncoding="UTF-8" /> <jsp:directive.page session="false" /> <jsp:output omit-xml-declaration="true" /> <div> <span id="mainNavNews" class="${currentController eq 'News' ? 'selectedItem' : ''}">foobar</span> </div> </jsp:root> With tomcat 7.0.50 it fails with the following exception: org.apache.jasper.JasperException: /WEB-INF/views/layouts/mainNavigation.jspx (line: 10, column: 87) "${currentController eq 'News' ? 'selectedItem' : ''}" contains invalid expression(s): javax.el.ELException: Failed to parse the expression [${currentControllereq'News'?'selectedItem':''}] at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42) at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443) at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:199) at org.apache.jasper.compiler.Validator$ValidateVisitor.getJspAttribute(Validator.java:1399) at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:772) at org.apache.jasper.compiler.Node$UninterpretedTag.accept(Node.java:1251) at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375) at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2427) at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:779) at org.apache.jasper.compiler.Node$UninterpretedTag.accept(Node.java:1251) at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375) at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2427) at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:529) at org.apache.jasper.compiler.Node$JspRoot.accept(Node.java:564) at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375) at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2427) at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2433) at org.apache.jasper.compiler.Node$Root.accept(Node.java:474) at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375) at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1817) at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217) at org.apache.jasper.compiler.Compiler.__compile(Compiler.java:373) at org.apache.jasper.compiler.Compiler.compile(Compiler.java) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) at org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:390) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) It works when the ternary operation doesn't appear inside an attribute or instead of eq '==' is used.
Happens with all named operators <span class="${foo == 'bar' and 1==1 ? 'bar-span' : 'other-span'}">span</span> will break as well. If used in jspx it only works now as <span class="${foo == 'bar' && 1==1 ? 'bar-span' : 'other-span'}">span</span> which is not a really acceptable solution.
Ack. Reproducible with your sample file from Comment 0 minus the 'xmlns:c' and 'xmlns:fmt' attributes. > javax.el.ELException: Failed to parse the expression [${currentControllereq'News'?'selectedItem':''}] Notes: 1. "currentControllereq" is printed without spaces in the above message. Also the rest of whitespaces are also missing in the message. 2. A workaround is to add braces around the variable name. The following does work: ... class="${(currentController) eq 'News' ? 'selectedItem' : ''}" ... 3. This issue happens when EL in the value of a tag attribute. This issue does not happen when EL is in the plain text (body of a tag). The following does work successfully: <jsp:root version="2.0" xmlns:jsp="http://java.sun.com/JSP/Page" ><jsp:directive.page contentType="text/plain"/> ${currentController eq 'News' ? 'selectedItem' : ''}</jsp:root>
(In reply to Konstantin Kolinko from comment #2) > Ack. Reproducible with your sample file from Comment 0 minus the 'xmlns:c' > and 'xmlns:fmt' attributes. > Reproducible in 8.0-RC10 and 6.0.38 (release candidate) as well.
I suspected when I read this report that it was a regression caused by the fix for Bug 55198 and given the versions of Tomcat affected it looks to be very much the case (although I haven't confirmed it yet).
Fixed in 8.0.x for 8.0.0 onwards and in 7.0.x for 7.0.51 onwards. Proposed for 6.0.x.
*** Bug 56031 has been marked as a duplicate of this bug. ***
Konstantin: Your addendum is fully correct, i can confirm this. Thanks for your kind reply and the quick solution, highly appreciated. Also thanks for the workaround, but i guess i'll wait to 7.0.51.
Created attachment 31231 [details] test.jspx - Failure to trim leading space from fn prefix Re: r1559555 Not yet. Testing current 7.0.x (at r1559663) I see the following error 1. Place attached test.jspx into webapps/examples 2. Access http://localhost:8080/examples/test.jspx 3. Expected: "[1]". Actual: org.apache.jasper.JasperException: /test.jspx (line: 7, column: 63) The attribute prefix fn does not correspond to any imported tag library org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:149) org.apache.jasper.compiler.Validator$ValidateVisitor$1FVVisitor.visit(Validator.java:1563) ... org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375) org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1817) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217) ... In the message the prefix is printed as " fn" with leading whitespace. The expression on the page is ${1 + fn:length(list)}
If fixed the white space issue in 8.0.x and 7.0.x and added it to the proposal for 6.0.x
This has been fixed in 6.0.x and will be included in 6.0.39 onwards.
*** Bug 56124 has been marked as a duplicate of this bug. ***
It seems this issue is fixed now. Can anyone advice in which 7.0.x version can I expect the fix to be delivered?
(In reply to Santosh from comment #12) > It seems this issue is fixed now. Can anyone advice in which 7.0.x version > can I expect the fix to be delivered? Santosh, Mark Thomson mentioned that will be in 8.0.0 and 7.0.51 onwards. Not sure when will the 7.0.51 be available.. :-)