If anyone like to compare a Enum value with JSP if tag there is a little surprise for him. JSP if tag do not support to compare a enum value directly in the test condition. For example a java Enum Employee.
public enum Employee {
PART_TIME,
FULL_TIME;
}
Now if you want to compare the Enum value in jsp if tag directly like following,
<c:if test="${bean.employee == '<%=Employee.PART_TIME%>'}">
.........
</c:if>
JSP generates error. But if you assign the value to a variable and compare then this is allowed as following
<c:set var="partTime" value="<%=Employee.PART_TIME%>"/>
<c:if test="${bean.employee == partTime'}">
.........
</c:if>
Advertisement

