fn:startsWith tag of Function Tag Library

What is "fn:startsWith" tag of Function Tag Library?

Explanation

"fn:startsWith" is a string function of JSP Standard Tag Library(JSTL). This function is used to check if the string starts with the given "prefix". Returns "true" if it does and "false" vice versa.
string.

Syntax:


boolean:fn:startsWith(string,prefix)

In the above syntax the "string" and "prefix" are of Data type "String".

Example :


<%@ taglib uri="http://java.sun.com/jsp/jstl/functions"
prefix="fn" %>
<p><b>String "Apple" starts with "n"::</b></p>
${fn:startsWith("Apple",'n')}

Result


String "Apple" starts with "n"::
false

In the above example we have checked the string "Apple" to find if it starts with the prefix "n". Since the string starts with "A" it returns "false".

Ask Questions

Ask Question