I have this in a jsp: <c:url value="/static" var="static" /> On tomcat 7.0.0 it is fine, but I tried running it on 7.0.4, and I'm getting: [static] is not a valid Java identifier I don't think this should be verified, because after all these are request attributes, so they do not collide with java keywords. Same goes for "class": [class] is not a valid Java identifier (Btw, 7.0.4 is not in the version list in bugzilla)
In and of itself, that tag will compile. The checks for Java identifiers were added to the EL processing so I suspect you have some illegal EL elsewhere on the page.
(In reply to comment #1) > In and of itself, that tag will compile. > > The checks for Java identifiers were added to the EL processing so I suspect > you have some illegal EL elsewhere on the page. Well, I removed all instance of "static" and then "class" started complaining. I didn't understand whether this is expected behaviour (part of EL spec, for example)
From JSP 2.2 EL specification: --------------------------------------- 1.14 Reserved Words The following words are reserved for the language and must not be used as identifiers. and eq gt true instanceof or ne le false empty not lt ge null div mod Note that many of these words are not in the language now, but they may be in the future, so developers must avoid using these words. --------------------------------------- I don't see "static" nor "class" in the list.
That part of the EL specification is mis-leading. The important part for this discussion is on page 21. Identifier ::= Java language identifier Java language identifier is defined by the Java Language Specification (JLS). Tomcat correctly limits valid EL identifiers based on the rules in the JLS.
*** Bug 51108 has been marked as a duplicate of this bug. ***
Hi guys, Can I beg a little advice? I think this is the right place to ask because others who encounter this bug may have the same question. EL has always lacked some kind of 'instanceof' operator for determining the type of an Object. In the past, a common workaround for this has been to do... ${foo.class.name == 'com.myapp.Person'} ...or... ${foo.class.simpleName == 'Person'} ...these aren't the greatest from a type-safety point of view, but they are quite readable and work fine. Note they are equivalent of writing (in Java): new Foo().getClass()' not 'Foo.class' (ie. they are calling the getter, not trying to use the Java keyword 'class') However now that 'class' is a reserved word in EL because of (as mentioned above)... Identifier ::= Java language identifier ...such EL expressons fail to compile. What is the suggested alternative? Regards, Richard.
Use the brace notation. ${foo['class'].name} The same story applies to Session#isNew() by the way. ${pageContext.session['new']}
Perfect! Thanks for that. Richard.