<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">These tags are used as a conditional statement in JSP. ; The <;c:choose>; works like a Java switch statement in that it lets you choose between a number of alternatives. Where the switch statement has case statements, the <;c:choose>; tag has <;c:when>; tags. A a switch statement has default clause to specify a default action and similar way <;c:choose>; has <;c:otherwise>; as default clause.</p>
<p> <b>Attribute:</b><br />
The <i><b><;c:choose>;</b></i> tag does not have any attribute.<br />
The <i><b><;c:when>; </b></i>tag has one attributes which is listed below.<br />
The <i><b><;c:otherwise>; </b></i>tag does not have any attribute.<br />
The <i><b><;c:when>;</b></i> tag has following attributes:</p>
<pre class="highlight" name="code"><;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>;
<;html>;
<;head>;
<;title>;<;c:choose>; Tag Example<;/title>;
<;/head>;
<;body>;
<;c:set var="salary" scope="session" value="${2000*2}"/>;
<;p>;Your salary is : <;c:out value="${salary}"/>;<;/p>;
<;c:choose>;
 <;c:when test="${salary <;= 0}">;
 Salary is very low to survive.
 <;/c:when>;
 <;c:when test="${salary >; 100000}">;
 Salary is very good.
 <;/c:when>;
 <;c:otherwise>;
 No comment sir...
 <;/c:otherwise>;
<;/c:choose>;
<;/body>;
<;/html>;
</pre>
<p>
As you can see above, <i><b><;c:choose>;-<;c:when>;-<;c:otherwise>; </b></i>tags JSP are similar to <i><b>if-elesif-else</b></i> blocks in JAVA. When you have multiple conditions and each of them produces different output, you can use <i><b><;c:choose>;-<;c:when>;-<;c:otherwise>;.</b></i></p>
<p> Make sure that there is no condition evaluation in <;c:choose>; block. This is enclosing tag for <;c:when>; and <;c:otherwise>; blocks.</p>
<p> <;c:when>; tag has condition evaluation capability and you can have multiple <;c:when>; blocks within single <;c:choose>; block. Each condition can be evaluated using test attribute of this statement.</p>
<p> <;c:otherwise>; block do not have any condition evaluation capability. It represents all conditions which are not covered by <;c:when>; statements. <;c:otherwise>; statement must be present in <;c:choose>; block.</p>
<div class="separator" style="clear: both; text-align: center;"><img border="0" src="http://50.87.249.200/~dineshon/wp-content/uploads/2013/10/3333.png" /></div>
</div>
</div>
<p></p>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/2013/10/jstl-if-tag.html">Previous</a> <;<; ; ; || <a href="https://dineshonjava.com/2013/10/jsp-standard-tag-library-jstl-tutorial.html">Index </a>||  ; >;>;<a href="https://dineshonjava.com/2013/10/jstl-import-tag.html">Next</a> >;>;</b></div>
<p>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/jstl-if-tag/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/jstl-import-tag/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '315'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…