JSTL Function fn:startsWith()

The function <fn:startsWith()> is a string function of JSTL. This function is used to check the input string starts with the given specified character or prefix. It returns true if it contains specified character otherwise returns false.

Syntax of JSTL Function <fn:startsWith()>

    boolean:fn:startsWith (java.lang.String, java.lang.String)

Example of JSTL Function <fn:startsWith()>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSTL fn:startsWith</title>

		String "JavaBeat" starts with "J":


Details of the Code

  • ${fn:startsWith(“JavaBeat”,’J’)} tag is used to check if the string starts with the given prefix. It returns true if result found correctly otherwise false.

Steps for Execution

  • Save this file as startsWith_example.jsp in your eclipse IDE.
  • Now select this jsp file, right mouse click and select Run as ->Run on server


When the execution process completed successfully we will get the following output:

Previous Tutorial :  JSTL Function fn:split()  :: Next Tutorial : JSTL Function fn:substring()

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This

Share this post with your friends!