Easy Tutorial
❮ Jsp Implicit Objects Jstl Function Containsignorecase ❯

fn:startsWith() Function

JSP Standard Tag Library

The fn:startsWith() function is used to determine if a string starts with a specified prefix.

Syntax

The syntax of the fn:startsWith() function is as follows:

<c:if test="${fn:startsWith(<original string>, <search prefix>)}">
            ...
</c:if>

Example Demonstration

The following example demonstrates the functionality of this function:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ 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>Using JSTL Functions</title>
</head>
<body>

&lt;c:set var="string" value="tutorialpro: I am from tutorialpro."/>
&lt;c:if test="${fn:startsWith(string, 'Google')}">
   <p>The string starts with Google</p>
</c:if>
<br />
&lt;c:if test="${fn:startsWith(string, 'tutorialpro')}">
   <p>The string starts with tutorialpro</p>
</c:if>

</body>
</html>

The output is as follows:

The string starts with tutorialpro

JSP Standard Tag Library

❮ Jsp Implicit Objects Jstl Function Containsignorecase ❯