Link to home
Create AccountLog in
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


ASKER CERTIFIED SOLUTION
Avatar of ioanton
ioanton

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of singh101
singh101

ASKER

Thanks - will probably change the field name to be more meaningful isWriteRoleAllowed
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