Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Jsp Use of Tag of JSTL

Related Tutorials


 
 

Share on Google+Share on Google+

Use of Tag of JSTL

Advertisement
In this section, you will learn how to use Tag of JSTL.

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 :

Download Source Code

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 24, 2008

Related Tutorials

Discuss: Use of Tag of JSTL  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com