Question

I have an object of type Employee in a session, called User and it contains the method

public String getType() {
    return type;
}

I want to use this value on a .jsp page using JSTL and i'm using the code

${sessionScope.User.getType eq 'Supervisor'}

to access this. But it keeps throwing an exception

PropertyNotFoundException: Property 'getType' not found on type model.Employee

and I can't figure out why. Please help.

Was it helpful?

Solution

The $ operator can read any object in the sessionScope and also other implicit object

Just type it like that

${User.type}

So the condition will be like that:

${User.type eq 'Supervisor'}

OTHER TIPS

JSLT EL adheres to the Java Beans specification.

Instead of using the method name use its bean shortname

For you code, it should be written as such:

${sessionScope.User.type eq 'Supervisor'}

Note 'type' not getType()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top