fn:escapeXml tag of Function Tag Library
What is "fn:escapeXml" tag of Function Tag Library?
Explanation
"fn:escapeXml" is a string function of JSP Standard Tag Library(JSTL). This function is used to replace all characters which have a special meaning in XML, HTML < > & to the corresponding character entity code < > & respectively.
Syntax:
String:fn:escapeXml(string)
In the above syntax the "string" is of data type "String". It returns a string. Example :
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"
prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions"
prefix="fn" %>
Character encoded string::${fn:escapeXml("romeo&juliet")}
Result in the HTML source code:
Character encoded string::romeo&juliet
In the above example we have used the "ampersand" symbol, whose character encoding is done using the fn:escapeXml function.