Reputation: 6006
Can I use el expressions in js functions that are on jsp page?
I have tried to do so, but the jsp compiler was always complaining that ==
symbol is not allowed here:
function somefunction() {
var booleanExpression = '${myBean.a == -1}';
....
}
myBean
is a request scope attribute that has an integer property a
. I also have tried to use eq
instead of ==
, but the error remains the same and that is weird.
I want my boleanExpression
to be true
or false
in result.
Upvotes: 2
Views: 3710
Reputation: 413712
Leave off the quotes.
var booleanExpression = ${myBean.a == -1};
JSP will dump out either true
or false
, with either of which JavaScript will be perfectly happy.
Upvotes: 2