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



Home Jsp Simple-jsp-example attribute escapeXml

Related Tutorials


 
 

Share on Google+Share on Google+

attribute escapeXml

Advertisement
One of the general purpose core library tag is . The main function of the this tag is to display the output to the user. It works like expression tag in jsp <%= ---%>.

<c: out> attribute escapeXml

        

One of the general purpose core library tag is <c: out>. The main function of the this tag is to display the output to the user. It works like expression tag in jsp <%= ---%>. 

Attributes of the <c: out> core action tag. 

  1. value: It specify the expression which needs to be evaluated. 
  2. default: We can use this attribute if the resulting value is null.
  3. escapeXml: It checks whether there is any need to convert the &, <, > etc to their character encoding codes. 

To see the desired result we need to use a core action tag <c: set> with a body. We are using this tag to differentiate between the escapeXml = true and escapeXml = false which is the attribute of <c: out> core action tag. We have used two attributes of <c: out>. The attribute value which is a must attribute and escapeXml attribute which takes a boolean value and is used to check whether there is any need to convert the &, <, > etc to their character encoding codes. Please go through this example and try to understand what is happening in the program.  

The code of the program is given below:

 

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
<head>
<title>The attribute escapeXml in c:out</title>
</head>

<body>
<c:set var="test" scope="session">
<table border="5">
We are going to use the attribute escapeXml of c:out to show the difference
<tr>
<td bgcolor="green">roseindia.net</td>

<td bgcolor="red">roseindia.net</td>
</tr>

<tr>
<td bgcolor="gray">roseindia.net</td>

<td bgcolor="yellow">roseindia.net</td>
</tr>
</table>
</c:set>

<h1>out with escapeXml=false</h1>
<c:out value="${test}" escapeXml="true" /><br>
<h3>out with escapeXml=false</h3>
<c:out value="${test}" escapeXml="false" />
<br />
</body>
</html>

The output of the program is given below:

Download this example.

Advertisements

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: March 12, 2008

Related Tutorials

Discuss: attribute escapeXml   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:3
muralidhar
January 30, 2012
Mistache in escapeXml=false

<h1>out with escapeXml=true</h1> <c:out value="${test}" escapeXml="true" /><br> <h3>out with escapeXml=false</h3> <c:out value="${test}" escapeXml="false" /> Here you have given h1 and h3 headers but both are having same size in webpage and the true and false are also assigned wrongly. Correct the code.
Vitalii
April 6, 2012
shiiiit

You have a mistake in your example. You print out "out with escapeXML=false" two times. Also, I would like to say that this resource is the most fucked up among all java goto sites. Hate it! Stop using fucking scriptlets in your examples, siriously!
Muralidhar
September 30, 2013
Error in Scripting

Hi please correct your code
DMCA.com