JSTL – fn:replace() Function

<%@ 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>Exmaple of JSTL - fn:replace() Function</title>
   </head>

   <body>
      <c:set var = "string1" value = ".Maui is awesome!"/>
      <c:set var = "string2" value = "${fn:replace(string1, 'awesome', 'great')}" />
      <p>Result : ${string2}</p>
   </body>
</html>
Result: .Maui is great!

Leave a Comment

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