Odd things happen with JSP <c:choose> <c:when> <c:if> -


a co-worker , came across situation in jsp, , wondering if stack overflow understand going on.

we having logical issue code looking this:

<c:if test="test something">   <c:choose>     <c:when test="test else">       <c:if test="yet again test"> //#1         <c:set "set stuff"/>       </c:if>     </c:when>     <c:otherwise> //#2       <c:if test="testing else">         <c:set "set else"/>       </c:if>     </c:otherwise>   </c:choose> </c:if> 

what noticing if test @ #1 failed never otherwise statement (#2). fixed combining (#1) test in above it.

can explain me why happens? inside (#1) failing kick logic out of conditionals together?

thanks in advance.

not sure trying do, code broken. c:otherwise used inside c:choice , not c:if

see code samples here

<c:choose>     <c:when test="${salary <= 0}">        salary low survive.     </c:when>     <c:when test="${salary > 1000}">         salary good.     </c:when>     <c:otherwise>         no comment sir...     </c:otherwise> </c:choose> 

and if:

<c:if test="${salary > 2000}">    <p>my salary is: <c:out value="${salary}"/><p> </c:if> 

note c:if not have support c:else or c:otherwise


Comments