I am having the strangest problem. Here is my code:

<c:set var="updAlloc" value="" />

<if test="${1==0}" >
   If Statement: ${1==0}
   <c:set var="updAlloc" value="disabled" />
</if>
Update Alloc equals ${updAlloc}

This is the output:

If Statement: false
Update Alloc equals disabled

Originally, I was testing a different variable, but realized that "${1==0}" was not even working properly. As you can see, even though the EL statement in the test condition evaluates to false, it still executes the body of the if statement.

My only guess is that something is wrong with my if syntax so it is ignoring it entirely. Can somebody help me with this?

Does that even work for you? Which version of JSTL are you using?

Anyways, it seems that JSTL forbids literal comparison. Instead of:

<c:if test="${1 == 0}">SOMETHING HERE</c:if>

try out something like:

<c:set var="x" value="1" />
<c:if test="${x == 0}">SOMETHING HERE</c:if>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.