<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><c:choose>,<c:when><c:otherwise>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>
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.