2017  Kodetalk | Feedback | Privacy Policy | Terms | About

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


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:when test="${param.enter=='1'}">

        some text.

        <br />   



    some text.        

    <br />   



Answer is