Example of JSTL fn:substringAfter() Function

Below is the implementation of JSTL fn:substringAfter() Function:

HTML




<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ 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>JSTL substringAfter Example</title>
  </head>
  <body>
    <c:set var="string1" value="Welcome to w3wiki."/>
      
    <c:set var="substringResult" value="${fn:substringAfter(string1, 'Geeks')}" />
      
    <p>Original String: ${string1}</p>
    <p>Substring after "Geeks": ${substringResult}</p>
  </body>
</html>


Output:

Explanation of the above Program:

  • In the above example, firstly we have initialised values to the string1 and substringResult variable as “Welcome to w3wiki” and the function output.
  • We are using the fn:substringAfter() Function in which we have passed the parameter of string1 and the delimiter as “Geeks“.
  • So we have got the result as forGeeks which is substring after Geeks delimiter.
  • We have printed the result in HTML by using the <p> tag.

JSTL fn:substringAfter() Function

In the main string, if we want to return the subset of the string followed by a specific substring then we can use the JSTL fn:substringAfter() Function.

Similar Reads

JSTL substringAfter() Function

This function mainly returns the portion of the string that comes after the given string value....

Example of JSTL fn:substringAfter() Function

Below is the implementation of JSTL fn:substringAfter() Function:...

Contact Us