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 :

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Use of Tag of JSTL
Post your Comment