Hello! Working with JSP pages and static imports using Tomcat's EL Jasper implementation, I found that importing a static field with EL lookup did not resolve to the correct value. Tried the following jsp <%@ page import = "static myapp.Example.STATIC_VAR, static myapp.Example.STATIC_METHOD" %> <html> <head> <title>Import Static</title> </head> <body> EL expressions: <br/> ${STATIC_VAR} ${STATIC_METHOD()} <br/> <br/> JSP expressions: <br/> <%=STATIC_VAR%> <%=STATIC_METHOD()%> </body> </html> The JSP expressions resolve as expected but of the EL expressions, only STATIC_METHOD() works. After some investigation we narrowed down that the problem may potentially be here https://github.com/apache/tomcat/blob/10.1.x/java/org/apache/el/parser/AstIdentifier.java#L101-L103 where the variable is resolved by the NotFoundELResolver and the import block to resolveStatic is not reached here https://github.com/apache/tomcat/blob/10.1.x/java/org/apache/el/parser/AstIdentifier.java#L105-L110. We are using the API from JakartaEE and not the API from Tomcat for Pages. If we change to Tomcat's API then it does behave as expected. This is because the ImportELResolver from Tomcat does a static lookup in its resolver here https://github.com/apache/tomcat/blob/10.1.x/java/jakarta/servlet/jsp/el/ImportELResolver.java#L85-L92 whereas the Jakarta API does not cover it here https://github.com/jakartaee/pages/blob/master/api/src/main/java/jakarta/servlet/jsp/el/ImportELResolver.java#L63-L71. Not sure if this should be fixed in the implementation of Tomcat or if it's something that should be address in the Jakarta Pages API. Any help is appreciated, thanks in advance!!
Here are a few clarifications for this issue, 1) This is for EE10 specifically, as we've tried to update our Open Liberty Pages Implementation to support static imports into the Expression Language environment. Before EE10, only JSP expressions could be used for this type of imports. 2) This scenario occurs with a mix up between Tomcat's EL API/Impl mixed with Jakarta Pages' 3.1 API. 3) Perhaps the Jakarta EE Pages API is more at fault and should be updated to look at static variables (via importHandler.resolveStatic), just as Tomcat ImportELResolver does. @Mark Thomas think you would know more here, any help would be appreciated! Thank you!
This looks like a Jakarta EL API bug to me. I think it needs to handle the static field. It also looks like the EvaluationListener#propertyResolved() events aren't being triggered.
Re-opening this as while Tomcat's pages API may handle this correctly, Jasper (Tomcat's pages implementation) does not.
Fixed in: - 11.0.x for 11.0.0-M3 onwards - 10.1.x for 10.1.6 onwards - 9.0.x for 9.0.72 onwards - 8.5.x for 8.5.86 onwards