2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

if…else within JSP or JSTL

Need some answer how to implement the below snippet by using JSTL.

if (Condition 1)
Some HTML code for con1
else if (Condition 2)
Some HTML code for con2

userimage

You two options to implement your snippet by using, either <c:if> or <c:choose> tags to make conditional rendering in jsp using JSTL.

To simulate if , you can use:
<c:if test="condition"></c:if>

To simulate if...else, you can use:
<c:choose>   

<c:when test="${param.enter=='1'}">

        some text.

        <br />   

</c:when>       

<c:otherwise>        

    some text.        

    <br />   

</c:otherwise>

</c:choose>

Answer is