Avatar of singh101
singh101
 asked on

How to access a boolean value on a object using JSTL

I have a User object defined as follows:

public class User implements Serializable {
         private String userId;
         private boolean writeRole;
      
      public User(String userId, boolean writeRole) {
            this.userId = userId;
            this.writeRole = writeRole;
      }
      
      public String getUserId() {
            return userId;
      }
      
      public boolean hasWriteRole() {
            return writeRole;
      }      
}

I have added an instance of this object to the httpsession.
in the JSP I am using JSTL to retrieve the writeRole property:

<c:if test="${sessionScope.adminuser.readRole}" >

This is throwing a compiler error javax.servlet.jsp.el.ELException: Unable to find a value for "writeRole" in object of class "com.examples.User" using operator "."

how can I access this value using JSTL?

Thanks In advance


JSP

Avatar of undefined
Last Comment
singh101

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ioanton

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
singh101

ASKER
Thanks - will probably change the field name to be more meaningful isWriteRoleAllowed
singh101

ASKER
I would be grateful if you could help me with the following related question

https://www.experts-exchange.com/questions/26608149/How-to-refer-to-a-constant-using-JSTL.html

Thanks In Advance
Your help has saved me hundreds of hours of internet surfing.
fblack61