You are here:   HomeJava Server PagesJava Standard Tag Lib (JSTL)JSTL Core c remove Tag

  <C:Choose>  Tag is similar to the Java Switch Statement In that case it allow us to choose desired statement that  has to be selected from substituted conditions. This tag has some more features like it has two more tags with it  Like <c:when> tag if the condition goes terminated to next step and the other one is <c: otherwise> works like default value in java switch case statement..And an attribute is also been used in the tag named “Test” that is used for evaluating Condition.

 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>

<head>

            <title>&lt;c:choose&gt;,&lt;c:when&gt;&lt;c:otherwise&gt;Tag Example In J.S.P</title>

</head>

<body>

             <p><b><br /><center>

             <c:set var="marks" scope="session" value="${800}"/>

             <p>Your Marks : <c:out value="${marks}"/></p>

      <c:choose>

            <c:when test="${marks >= 800}">

                 ${" And You Got First Division"}

           </c:when>

           <c:when test="${Marks < 800}">

                ${"And You Got Second Division"}

          </c:when>

              <c:otherwise>

                  ${"Passed"}

             </c:otherwise>

      </c:choose></center></b></p>

</body>

</html>

                    JSTL Core c choose Tag

 Description about the Program Of <c: choose> tag in JSTL

 According to the requirement as we call the tag lib (tag library) for accessing the “CORE” tags In JSTL.

This tag is used as the java switch case statement in it’s own preference like with the <c: choose> we also use the   

<c: when> and <c: otherwise>. To declare all the mandatory HTML tags for functioning. In the first session we set    the variable name that will store the value of output and set the value as per the condition the first step has to be choose if its got terminated then other will be used to full fill the requirements like testing condition with the tag <c: when> and all the condition or statements goes cleared the default value will be printed on browser a s the output <c: otherwise> in JSTL. In the last all the tags will be closed.





About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.



What's New and Popular