<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Robin&#039;s Tech Tips &#187; escape</title>
	<atom:link href="http://robin.mytechtip.com/tag/escape/feed/" rel="self" type="application/rss+xml" />
	<link>http://robin.mytechtip.com</link>
	<description>Just another My Tech Tip weblog</description>
	<lastBuildDate>Wed, 06 Jul 2011 02:35:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Encode/Decode HTML in Java</title>
		<link>http://robin.mytechtip.com/2009/02/04/encode-decode-html-in-java/</link>
		<comments>http://robin.mytechtip.com/2009/02/04/encode-decode-html-in-java/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 00:17:48 +0000</pubDate>
		<dc:creator>robin</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[escape]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://robin.mytechtip.com/?p=22</guid>
		<description><![CDATA[


It is often necessary to escape the special html code from the user input in case of avoiding cross site attack (XSS).
Initially i thought jdk provides a method somewhere to do this like function htmlentities()  in php, but i failed to find it. All i found is a class called &#8220;URLEncoder &#8221; which i [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-3371750151985752";
google_ad_slot = "0950801022";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>It is often necessary to escape the special html code from the user input in case of avoiding cross site attack (XSS).</p>
<p>Initially i thought jdk provides a method somewhere to do this like function <strong><a id="h39v" title="htmlentities()" href="http://www.php.net/htmlentities" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.php.net');">htmlentities()</a> </strong> in php, but i failed to find it. All i found is a class called &#8220;<strong><a id="voha" title="URLEncoder" href="http://java.sun.com/javase/6/docs/api/java/net/URLEncoder.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/java.sun.com');">URLEncoder</a> </strong>&#8221; which i don&#8217;t think can do this job.</p>
<p>I don&#8217;t want to reinvent the wheel as I believe there must be some java packages available that do this job. Googling &#8220;java encode html&#8221; didn&#8217;t lead me straight to the right java package (at least not the one I&#8217;d like to use).</p>
<p>After a while, I finally found one package i&#8217;d like to use. it&#8217;s from Apache Commons project, called &#8220;<a id="o-id" title="Commons Lang" href="http://commons.apache.org/lang/" onclick="javascript:pageTracker._trackPageview('/outbound/article/commons.apache.org');">Commons Lang</a>&#8220;. The method &#8220;<a id="fjhq" title="StringEscapeUtils.escapeHtml(...)" href="http://commons.apache.org/lang/api-release/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml%28java.lang.String%29" onclick="javascript:pageTracker._trackPageview('/outbound/article/commons.apache.org');">StringEscapeUtils.escapeHtml(&#8230;)</a> &#8221; can do the encode job while the other method called unescapeHtml can do the decode job. So, I don&#8217;t have to write my own method&#8230; <img src='http://robin.mytechtip.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://robin.mytechtip.com/2009/02/04/encode-decode-html-in-java/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

