I encountered a strange problem when displaying a boolean
property of a Java bean in jsp. It appears that a getter called isEmpty()
causes a ParseException on the EL parser.
For demonstration purposes I created a class that shows the problem.
public class Bookcase {
public boolean isWithoutContent() {
return true;
}
public boolean isEmpty() {
return true;
}
}
Calling on the properties in jsp:
${bookcase.withoutContent}
${bookcase.empty}
The first shows true
while the second throws an error:
org.apache.el.parser.ParseException: Encountered " "empty" "empty ""
at line 1, column 23.
Was expecting:
<IDENTIFIER> ...
Now I know there's an EL empty
operator but clearly the dot operator suggests I'm invoking the isEmpty()
method on the bookcase
object? Well apparently not, considering the error.
On the actual bean I cannot / do not want to rename the isEmpty()
method, but how do I display this property in jsp?