I have a Java object User in my servlet, which I assign to the request parameter "user" in my JSP.
This user has a boolean method hasConfidentialAccess(), which returns true or false. I want to call this in my jsp like the following:
<c:if test="${user.hasConfidentialAccess}">
...
</c:if>
But this doesn't work, my console throws following exception:
11:34:49,978 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/watson].[BasicSearchControllerServlet]] (http-/0.0.0.0:8080-7) JBWEB000236: Servlet.service() for servlet BasicSearchControllerServlet threw exception: javax.el.PropertyNotFoundException: The class 'com.commons.framework.security.DefaultUser' does not have the property 'hasConfidentialAccess'.
How to make this work?
EL does support accessing isX() methods directly as if you were accessing a getX() method, but only if the return type of the isX() method is a primative boolean.
If you return an object of any kind (such as Boolean isObjectBooleanTrue()) then EL fails to find the method and will give you a rather nasty EL exception: javax.el.PropertyNotFoundException: The class 'com.User' does not have the property 'isConfidentialAccess'.
So yes, 'is' methods work in EL but make sure you ONLY return primitive booleans from them.
Specific to your problem: