Skip to main content
Kinetic Community

JSTL Functions Tag Library

The JSTL Functions tag library contains a number of standard functions, most of which are common string manipulation functions.

Getting Started

Configuration

The JSTL Functions tag library can be declared with the following taglib directive:

<%-- bundle/initialization.jspf --%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/fn" %>

Usage

<%-- form.jsp --%>
...
<c:if test="${fn:length(param.username) > 0}" >
  <%@include file="response.jsp" %>
</c:if>
...

Tags

The following tags are provided in the functions tag library:

${fn:contains()}

Tests if an input string contains the specified substring.

${fn:containsIgnoreCase()}

Tests if an input string contains the specified substring in a case insensitive way.

${fn:endsWith()}

Tests if an input string ends with the specified suffix.

${fn:escapeXml()}

Escapes characters that could be interpreted as XML markup.

${fn:indexOf()}

Returns the index within a string of the first occurrence of a specified substring.

${fn:join()}

Joins all elements of an array into a string.

${fn:length()}

Returns the number of items in a collection, or the number of characters in a string.

${fn:replace()}

Returns a string resulting from replacing in an input string all occurrences with a given string.

${fn:split()}

Splits a string into an array of substrings.

${fn:startsWith()}

Tests if an input string starts with the specified prefix.

${fn:subString()}

Returns a subset of a string.

${fn:subStringAfter()}

Returns a subset of a string following a specific substring.

${fn:subStringBefore()}

Returns a subset of a string before a specific substring.

${fn:toLowerCase()}

Converts all of the characters of a string to lower case.

${fn:toUpperCase()}

Converts all of the characters of a string to upper case.

${fn:trim()}

Removes white spaces from both ends of a string.

Related