What is the precedence of ambiguous (boolean / int) accessories in the JSP expression language?
I am dealing with a legacy system that has a Java bean with this (trimmed / masked) snippet:
public class AmbiguousJspElBean {
private int ambiguous;
public int getAmbiguous() {
return ambiguous;
}
public void setAmbiguous(int ambiguous) {
this.ambiguous = ambiguous;
}
public boolean isAmbiguous() {
return ambiguous == 1;
}
}
My questions:
-
If I am trying to reference a
ambiguous
JSP expression language through${bean.ambiguous}
, what is the precedence the interpreter uses to find the right accessor?and. I tested it and it looks like a method in practice
isAmbiguous()
, but it will always be like this / depends / does it depend on the interpreter I am using? -
Should I instead
${bean.isAmbiguous()}
(potentially) mitigate any ambiguity for future on-lookers?
As I said, this is a legacy system, so modifying the original class to turn ambiguous
into boolean
instead is int
not an option.
source to share
Looks like there was already and answered , default for boolean public boolean is<PropertyName>()
accessor.
source to share