I have a servlet that stores an object in request scope and subsequently includes a JSP page. In that JSP page, I have these two lines: <% System.out.println(request.getAttribute("validate-error") != null); %> <c:out value='${request.validate-error != null}'/><br/> If the object is in request scope, the scriplet prints true; otherwise, it prints false. That's what I expected. Regardless of whether the object is present, the <c:out> tag always prints true. I believe the scriplet and <c:out> action should behave identically. Oddly enough, if I test against a request parameter instead of a request attribute, the <c:out> action works correctly.
Technically, this is not a bug. The problem is that "-" is not a valid character in an identifier, so the expression is being interpreted as: ${ (request.validate) - (error) != null } which, after going through all our coercion rules, ends up being 0!=null, or true. To get the desired behavior, the identifier has to be quoted: ${request."validate-error" != null } This should work properly. Having said all that, this definitely looks like a usability issue. It would be nice if the user could somehow be told that "-" is being used as an operator, which should give some clue as to what's going on. Perhaps if we changed "null - null" to be an error, that would work, but I think there would be many other undesirable effects of doing that. In the end, I don't think there's much that can be done besides better documentation, and perhaps discouraging people from using non-Java identifiers.
A clarification - quoted identifiers are not actually part of the specified language anymore (bug 7658), so the desired behavior should be obtained like this: ${request ["validate-error"] != null }