JSTL CHOOSE

how in jstl can i do the following:i got a var called X, i want to test if X is not equeal to A, not equal to B, and not equal to C, using the c:choosec:when, but in a valid xml page.not to sure about the syntax
[232 byte] By [Reniera] at [2007-11-26 15:19:36]
# 1

Assuming that's an 'and condition and that A, B and C are also variables,

<c:choose>

<c:when test = ${X ne A && X ne B && X ne C}>

//do something

</c:when>

<c:otherwise>

//do some other thing

</c:otherwise>

</c:choose>

If A, B and C are String constants, then the above would change to

<c:when test = ${X ne 'A' && X ne 'B'&& X ne 'C'}>

And finally if that isnt an 'and' operation

<c:choose>

<c:when test = ${X ne A}>

//do something

</c:when>

<c:when test = ${X ne B}>

//do some other thing

</c:when>

<c:when test = ${X ne C}>

//do yet another thing

</c:when>

</c:otherwise>

//process

</c:otherwise>

</c:choose>

ram.

Madathil_Prasada at 2007-7-8 11:46:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks but my code must be xml valid, so i must use the encode versions of & and <> which is &&and <>

I trid this but it still give an error:

fnbQ is a variable, and a b and c are strings

<c:choose>

<c:when test="${finQ &lt;&gt; 'A' &amp;&amp; finQ &lt;&gt; 'B' &amp;&amp; finQ &lt;&gt; 'C' &amp;&amp; finQ &lt;&gt; 'D'}">

......

</c:when>

</c:choose>

Reniera at 2007-7-8 11:46:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Will you post the error? I am sure it has something to do with the xml format for the EL operators you have provided.ram.
Madathil_Prasada at 2007-7-8 11:46:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

You can use words instead of symbols for operations:

&& = and

|| = or

<> = ne

That would avoid all the nastiness with escaping right?

<c:when test="${finQ ne 'A' and finQ ne 'B' and finQ ne 'C' and finQ ne 'D'}">

evnafetsa at 2007-7-8 11:46:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...