Home Tutorial Java Jsp The fn:toUpperCase & fn:toLowerCase tags of JSTL

 
 

Share on Google+Share on Google+
The fn:toUpperCase & fn:toLowerCase tags of JSTL
Posted on: July 3, 2010 at 12:00 AM
Advertisement
In this section ,we will learn how to use fn:toUpperCase and fn:toLowerCase Tag of JSTL.

The fn:toUpperCase & fn:toLowerCase tags of JSTL

In this section ,we will learn how to use fn:toUpperCase and  fn:toLowerCase Tag of JSTL. These tags are used to change case of specified string to upper or lower. This takes string type as argument.

EXAMPLE:

In this Example, the user enters the value of string, which he wants to change it's case(i.e lowercase or uppercase). The c:if tag of JSTL checks whether requirement is 'uppercase' or' lowercase' & convert it accordingly using  "fn:toUpperCase()" or " fn:toLowerCase()" method of JSTL.

changeCaseJSTL.jsp

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

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

<html>

<head>

<title>Example of 'fn:toUpperCase' and 'fn:toLowerCase' tag of jstl</title>

</head>

<body bgcolor="grey">

<form method="POST">

Enter String here and select case as per your choice.

<table>

<tr>

<td>Enter String</td>

<td><input type="text" name="string"></td>

</tr>

<tr>

<td></td>

<td><input type="radio" name="case" value="upper"> Upper Case

<input type="radio" name="case" value="lower"> Lower Case </td>

</tr>

<tr>

<td></td>

<td><input type="submit" value="change"></td>

</tr>

</table>

</form>

<c:if test="${pageContext.request.method=='POST'}">

<c:set var="string" value="${param.string}"/>

<font size="5" color="green">

<c:if test="${param.case=='upper'}">

<c:out value="${fn:toUpperCase(string)}"/>

</c:if>

<c:if test="${param.case=='lower'}">

<c:out value="${fn:toLowerCase(string)}"/>

</c:if>

</font>

</c:if>

</body>

</html>

OUTPUT :

After submitting Value the output will be :

Download Source Code

Advertisement

Related Tags for The fn:toUpperCase & fn:toLowerCase tags of JSTL:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 3, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com