0

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?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by ~s.o.s~
0

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>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.