Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Jsp Choose 
 

In this section, you will learn how to use JTSL choose tag.

 

Jsp Choose

                          

In this section, you will learn how to use JTSL choose tag. 

In the given example, the c:if tag is used for a decision need, to be made in the page. If the result of processing the test using the EL Expression pageContext.request.method=='POST' is true, the body of the tag is processed otherwise it is skipped. In order to make a multi-way choice, we have used c:choose JTSL tag. You can include any number of c:when clauses but a single c:otherwise tag that will generate the template text if the entered value equals anything else, inside a c:choose tag. Here we prompt the user to enter only vowels, if the entered value is vowel, it will return true otherwise false.

 

 

Here is the code of choose.jsp

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
<body>
<c:if test="${pageContext.request.method=='POST'}">You have entered:
<c:choose>
<c:when test="${param.choose=='a'}">true value
<br />
</c:when>
<c:when test="${param.choose=='e'}">true value
<br />
</c:when>
<c:when test="${param.choose=='i'}">true value
<br />
</c:when>
<c:when test="${param.choose=='o'}">true value
<br />
</c:when>
<c:when test="${param.choose=='u'}">true value
<br />
</c:when>
<c:otherwise>
false value
<br />
</c:otherwise>
</c:choose>
</c:if>
<form method="post">Enter only vowels:
<input type="text" name="choose" />
<input type="submit" value="Submit" />
<br />
</form>
</body>
</html>

Output will be displayed as:

If you enter any vowel and click button, it will display the text that the entered value is true:

But if you enter any alphabet or number other than vowels, it will display the text that you have entered false value:

Download Source Code:

 

                          

» View all related tutorials
Related Tags: c jsp class constructor object io struct method sed const value name return declaration ai like js define example constructors

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.