JSTL fn:startsWith() function

The JSTL fn:startsWith() function is used to check whether the input string is starts with the specified string or not. It returns true if input string is starts with the specified string otherwise return false.

Syntax: boolean startsWith(String inputString, String specifiedString)

Example:

test.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
 
<html>
	<head>
		<title>fn:startsWith JSTL function example</title>
	</head>
	<body>
		<c:set var="testString" 
                   value="Hello this is a JSTL function example."/>
 
		<c:if test="${fn:startsWith(testString, 'Hello')}">
		   <h4>String starts with Hello.</h4>
		</c:if>
	</body>
</html>

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>test.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>

Output:

jsp example 54
 
Download this example.
 
Next Topic: JSTL fn:endsWith() function with example.
Previous Topic: JSTL fn:containsIgnoreCase() function with example.

Related Topics:

JSTL fn:contains() function with example.
JSTL fn:containsIgnoreCase() function with example.
JSTL fn:startsWith() function with example.
JSTL fn:endsWith() function with example.
JSTL fn:escapeXml() function with example.
JSTL fn:indexOf() function with example.
JSTL fn:join() and fn:split() function with example.
JSTL fn:length() function with example.
JSTL fn:replace() function with example.
JSTL fn:subString() function with example.
JSTL fn:subStringAfter() function with example.
JSTL fn:subStringBefore() function with example.
JSTL fn:toLowerCase() function with example.
JSTL fn:toUpperCase() function with example.
JSTL fn:trim() function with example.