Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


Java Tutorials



Struts Tutorials

Struts Resources

Visit Forum! Post Questions!
Jobs At RoseIndia.net!

JSTL Functions

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

In this example we are using the tag <c: set> for setting the value in the variable named var. We are going to use the various functions provided to us by the jstl functions library. 

The JSTL functions library has many methods. We have used some methods to describe the functioning of this library.

length(string): It returns the numbers of characters in the string.

contains(java.lang.String,  java.lang.String): It checks whether the given string contains the specified string.

split(java.lang.String, java.lang.String): It splits the string into an array of substrings.

toUpperCase(string): It converts the string to upper case.

toLowerCase(string): It converts the string to a lower case.

substring("String", first index, last index): It returns a subset of a string. 

The code of the program is given below:

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<head><title>Using the JSTL functions</title></head>
<h2>Using JSTL functions</h2>
<c:set var="string" value="Welcome! to the site of roseindia.net"/>
The length of the String: ${fn:length(string)}<br>

Does the String contain "Welcome"? ${fn:contains(string,"Welcome")}<br>

Splits a string into an array of substrings using fn:split() : ${fn:length(fn:split(string," "))}<br>

Ignore the case : ${fn:containsIgnoreCase(string, "Welcome")}<br>

Converting the String into upper case using fn:toUpperCase(): ${fn:toUpperCase(string)}<br>

Converting the String into lower case using fn:toLowerCase(): ${fn:toLowerCase(string)}<br>

Making the substring of "roseindia.net" : ${fn:substring("roseindia.net", 0,9)}


The output of the program is given below:

Download this program.









[an error occurred while processing this directive]