This question already has an answer here:
- How to reference constants in EL? 12 answers
I'm trying compare two enum values in JSTL. In my Tomcat works fine, but when I deploy the application in a Jboss doesn't work.
Enum class:
public enum Status {
VALID,
NOT_VALID,
OTHER,
;
public String getName() {
return name();
}
}
Piece of JSP:
...
<%@ page import="my.package.Status" %>
...
<c:choose>
<c:when test="${myVar.status.toString() == Status.VALIDAD.toString()}">
<c:set var="clase" value="green-text" />
</c:when>
<c:when test="${myVar.status.toString() == Status.NOT_VALIDADO.toString()}">
<c:set var="clase" value="yellow-text" />
</c:when>
<c:otherwise>
<c:set var="clase" value="red-text" />
</c:otherwise>
</c:choose>
<span class="${clase}">
<%-- Output tests --%>
[${myVar.status}] - <%-- Works in Tomcat and Jboss --%>
[${Status.VALIDAD.toString()}] - <%-- Works in Tomcat, empty in Jboss --%>
[${Status.VALIDAD}] - <%-- Works in Tomcat, empty in Jboss --%>
[${Status.VALIDAD.name}] - <%-- Works in Tomcat, empty in Jboss --%>
[${Status.VALIDAD.name()}] <%-- Works in Tomcat, empty in Jboss --%>
</span>
I have readed this and this, but I don't understand because works in Tomcat and not in Jboss.
Some idea?
EDIT:
I have tried with Jboss EAP 7.0.0 that includes the library jboss-el-api_3.0_spec-1.0.6.Final-redhat-1.jar
, but still doesn't work. Also I have tested with Java 1.7 and Java 1.8.
Most likely your JBoss uses another JSP/Servlet API version than your Tomcat.
From another question related to this one: