Use of <fn:escapeXml(String)> Tag of JSTL
In this section we will learn how to use <fn:escapeXml>
Tag of JSTL. This tag is used to escape characters that could be interpreted as
XML markup. This takes string type as argument and also returns string type.
| Syntax : |
java.lang.String escapeXml(java.lang.String) |
escapeXml_fnJstlTag.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
<title>Example of fn:escapeXml Tag</title>
</head>
<body>
<c:set var="str1" value="This is first String."/>
<c:set var="str2" value="This <abc>is second String.</abc>"/>
<c:set var="str3" value="<mahendra>This is first String.</mahendra>"/>
<h4>fn:escapeXml</h4>
<table border="1">
<tr>
<th>without fn:escapeXml</th>
<th>with fn:escapeXml</th>
</tr>
<tr>
<td>${str1}</td>
<td>${fn:escapeXml(str1)}</td>
</tr>
<tr>
<td>${str2}</td>
<td>${fn:escapeXml(str2)}</td>
</tr>
<tr>
<td>${str3}</td>
<td>${fn:escapeXml(str3)}</td>
</tr>
</table>
</body>
</html>
This jsp code shows the following output :



