Bug 50120

Summary: .class in a jsp results in an invalid idetifier
Product: Tomcat 7 Reporter: joker8achtung1
Component: JasperAssignee: Tomcat Developers Mailing List <dev>
Severity: normal CC: eugene.petrenko
Priority: P2    
Version: 7.0.2   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description joker8achtung1 2010-10-20 04:04:38 UTC
when trying to access a getClass() method within a jsp, the following exception occurs:

org.apache.jasper.JasperException: /jsp/example.jsp(68,6) "${memBean.class.name == text}" 
contains invalid expression(s): javax.el.ELException: [class] is not a valid Java identifier

is this a bug or a desired feature of 7.0.2?

as far as i've noticed, the validation is done in org.pache.el.util.Validation whereby invalidIdentifiers contains the class keyword
by the way, validation is done currently case-insensitive, so *.Class.Name would be a work-around
Comment 1 Mark Thomas 2010-10-20 06:39:52 UTC
This is spec required behaviour. Further questions should be addressed to the users mailing list.
Comment 2 Konstantin Kolinko 2010-10-20 06:48:36 UTC
"class" is a reserved word in Java. Note, that you can write your expression as
"${memBean['class'].name == text}"
Comment 3 Mark Thomas 2010-11-15 07:48:45 UTC
*** Bug 50272 has been marked as a duplicate of this bug. ***
Comment 4 Eugene Petrenko 2010-11-15 09:48:01 UTC
This is the breaking change for us to switch to Tomcat7. We have quite a big codebase to search for keyword usages in .jsp/.tag files. Is there a property/parameters/setting to enforce older behavior (like in 6.0) of jsp compiler?
Comment 5 Mark Thomas 2010-11-15 10:51:46 UTC
The same fix has been / will be applied to Tomcat 6.

In the short-term you can use org.apache.el.parser.SKIP_IDENTIFIER_CHECK to bypass the check but that is not a viable long term solution. As time consuming as it may be, you'll need to review your apps for illegal EL and fix any issues.
Comment 6 Konstantin Kolinko 2010-11-15 10:57:23 UTC

*** This bug has been marked as a duplicate of bug 49217 ***