Java jstl function endswith

www‮itfigi.‬dea.com

The JSTL (JavaServer Pages Standard Tag Library) fn tag library provides a set of functions for manipulating strings, collections, and other objects in JSP (JavaServer Pages) pages. One of the functions in the fn tag library is the fn:endsWith function, which is used to check if a string ends with a specified suffix.

The fn:endsWith function takes two arguments: a string and a suffix to check for. The function returns a boolean value indicating whether the string ends with the specified suffix. The syntax of the function is as follows:

${fn:endsWith(string, suffix)}

where string is the string to check, and suffix is the suffix to check for.

For example, to check if a string ends with the suffix "ing", you would use the following expression:

${fn:endsWith('example string', 'ing')}

This expression returns true, because the string "example string" ends with the suffix "ing".

You can also use variables instead of literals for the string and suffix arguments. For example, if you have a variable text containing a string, you can check if it ends with the suffix "ing" using the following expression:

${fn:endsWith(text, 'ing')}

This expression returns true if the variable text ends with the suffix "ing".

Note that the fn tag library must be imported at the beginning of the JSP page using the following tag:

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

This imports the fn tag library and assigns it a prefix of fn.