<?xml version="1.0"?><rss version="2.0">
<channel>
  <title>Java Beans dot Asia - javascript category</title>
  <link>http://javabeans.asia/categories/javascript/</link>
  <description>Just a few simple tutorials</description>
  <language>en</language>
  <copyright>Alexander Zagniotov</copyright>
  <lastBuildDate>Tue, 23 Feb 2010 11:04:00 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  <image>
    <url>/images/blog-image.jpg</url>
    <title>Java Beans dot Asia (javascript category)</title>
    <link>http://javabeans.asia/</link>
  </image>
  <item>
    <title>Enriching Rich Internet Applications with rule-based reasoning</title>
    <link>http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html</link>
	 <description>
        I came across a Firefox &lt;a target=&#034;_blank&#034; title=&#034;Firefox add-on web rules - Drools-like condition language&#034; href=&#034;https://addons.mozilla.org/en-US/firefox/addon/8098&#034;&gt;Add-On&lt;/a&gt; today by Matthias Tylkowski, that lets user to modify the browser view of his/her  preferred web pages. For example, user can modify the appearance of &lt;a target=&#034;_blank&#034; title=&#034;CNN News&#034; href=&#034;http://www.cnn.com&#034;&gt;cnn.com&lt;/a&gt; to suit his/her needs.&lt;br /&gt;
&lt;br /&gt;
The add-on or the web rules is a JSON-based rule language, where each rule is a JSON object. In addition, Javascript is used for method calls. The web rules use Drools-like condition language:
&lt;pre name=&#034;code&#034; class=&#034;java:firstline[1]&#034;&gt;{&amp;quot;id&amp;quot;:&amp;quot;rule101&amp;quot;,&lt;br /&gt;  &amp;quot;appliesTo&amp;quot;: [&lt;br /&gt;       &amp;quot;http://www.cnn.com&amp;quot;&lt;br /&gt;     ],&lt;br /&gt; &amp;quot;condition&amp;quot;:&lt;br /&gt;  &amp;quot;$X:Element( class == &#039;note&#039;,&lt;br /&gt;               $Y:firstChild&lt;br /&gt;             )&lt;br /&gt;             &amp;amp;&amp;amp;&lt;br /&gt;             ($Y.nodeName == &#039;ul&#039;)&amp;quot;,&lt;br /&gt; &amp;quot;actions&amp;quot;:[&lt;br /&gt;  &amp;quot;changeBackground($Y, &#039;blue&#039;)&amp;quot;&lt;br /&gt;   ]&lt;br /&gt; }&lt;/pre&gt;
For all elements of class &lt;strong&gt;&lt;em&gt;note&lt;/em&gt;&lt;/strong&gt; having as first child an &lt;strong&gt;&lt;em&gt;ul&lt;/em&gt;&lt;/strong&gt;, change the first child background color to blue.&lt;strong&gt;&lt;br /&gt;
&lt;/strong&gt;&lt;br /&gt;
I think its a quite cool add-on.&lt;br /&gt;
&lt;br /&gt;
Resources:&lt;br /&gt;
&lt;em&gt;&lt;a href=&#034;http://bpt.hpi.uni-potsdam.de/pub/Public/EmilianPascalau/JSONRulesSlides.pdf&#034; target=&#034;_blank&#034;&gt;JSON Rules&lt;/a&gt;&lt;/em&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;t=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;t=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;i&gt;There are no related posts for this blog entry&lt;/i&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          I came across a Firefox Add-On today by Matthias Tylkowski, that lets user to modify the browser view of his/her  preferred web pages. For example, user can modify the appearance of cnn.com to suit his/her needs.  The add-on or the web rules is a JSON-based rule language, where each rule is a JSON object. In ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;t=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;title=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html&amp;amp;t=Enriching Rich Internet Applications with rule-based reasoning&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>json</category>
    <category>drools</category>
    <category>javascript</category>
    <comments>http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2010/02/23/enriching_rich_internet_applications_with_rule_based_reasoning.html</guid>
    <pubDate>Mon, 22 Feb 2010 14:00:00 GMT</pubDate>
  </item>
  <item>
    <title>Redefining web applications with AJAX, Servlets and JSON</title>
    <link>http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html</link>
	 <description>
        In this article I would like to show how JSON (JavaScript Object Notation) and Java servlet can be used together in a little AJAX (Asynchronous JavaScript and XML) application. &lt;br /&gt;
&lt;br /&gt;
To give brief description to those who are not closely familiar with JSON - &lt;br /&gt;
JSON is a lightweight syntax for representing data, which makes working with it much more pleasant than with XML and makes AJAX applications faster. Also, when working with JSON, there is no need for an XML parsing.&lt;br /&gt;
&lt;br /&gt;
In the following example, I am going to create a callback servlet that fetches and parses an RSS feed. Then the parsed feed data is passed to the client side in a form of JSON. The data then formatted and presented to the user. The client uses AJAX call to query the servlet.&lt;br /&gt;
&lt;br /&gt;
For this application, I used three third-party libraries:&lt;br /&gt;
&lt;ol&gt;
    &lt;li&gt;&lt;strong&gt;JSON library&lt;/strong&gt; provided by &lt;a title=&#034;JSON&#034; target=&#034;_new&#034; href=&#034;http://json.org/java/&#034; onclick=&#034;javascript:pageTracker._trackPageview(&#039;/outbound/article/json.org&#039;);&#034; rel=&#034;nofollow&#034;&gt;JSON.org&lt;/a&gt; and extended by &lt;a target=&#034;_blank&#034; href=&#034;http://oss.metaparadigm.com/jsonrpc/index.html&#034;&gt;JSON-RPC-Java&lt;/a&gt; which allows to create and easily parse JSON data through Java code. This library can run in a Servlet container such as Tomcat, JBoss and other J2EE Application servers.&lt;/li&gt;
    &lt;li&gt;&lt;a href=&#034;https://rome.dev.java.net/&#034; target=&#034;_blank&#034; title=&#034;Project ROME&#034;&gt;Project ROME&lt;/a&gt;&lt;br /&gt;
    ROME is an set of open source Java tools for parsing, generating and publishing RSS and Atom feeds.&lt;/li&gt;
    &lt;li&gt;&lt;a href=&#034;http://jdom.org&#034; target=&#034;_blank&#034; title=&#034;JDOM XML parser&#034;&gt;JDOM XML parser&lt;/a&gt;&lt;br /&gt;
    JDOM is a Java-based &amp;quot;document object model&amp;quot; for XML files. JDOM serves the same purpose as DOM, but is easier to use&lt;/li&gt;
&lt;/ol&gt;
The libraries are included in the source code which accompanies this article. This application example is also included as a &lt;a href=&#034;http://javabeans.asia/files/src/json_servlets_ajax_war.zip&#034; title=&#034;WAR archive&#034;&gt;WAR&lt;/a&gt; archive, ready to be deployed on Tomcat.&lt;br /&gt;
&lt;br /&gt;
The following is my servlet implementation. The servlet fetches and parses feed data. The JSON library mentioned previously allows me easily to create and populate JSON object.&lt;br /&gt;
&lt;pre class=&#034;java&#034; name=&#034;code&#034;&gt;package asia.javabeans.json;&lt;br /&gt;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;import java.net.MalformedURLException;&lt;br /&gt;import java.net.URL;&lt;br /&gt;import java.util.List;&lt;br /&gt;&lt;br /&gt;import javax.servlet.ServletConfig;&lt;br /&gt;import javax.servlet.ServletException;&lt;br /&gt;import javax.servlet.http.HttpServlet;&lt;br /&gt;import javax.servlet.http.HttpServletRequest;&lt;br /&gt;import javax.servlet.http.HttpServletResponse;&lt;br /&gt;&lt;br /&gt;import org.json.JSONArray;&lt;br /&gt;import org.json.JSONObject;&lt;br /&gt;&lt;br /&gt;import com.sun.syndication.feed.synd.SyndEntry;&lt;br /&gt;import com.sun.syndication.feed.synd.SyndFeed;&lt;br /&gt;import com.sun.syndication.fetcher.FeedFetcher;&lt;br /&gt;import com.sun.syndication.fetcher.FetcherException;&lt;br /&gt;import com.sun.syndication.fetcher.impl.FeedFetcherCache;&lt;br /&gt;import &lt;br /&gt;com.sun.syndication.fetcher.impl.HashMapFeedInfoCache;&lt;br /&gt;import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher;&lt;br /&gt;import com.sun.syndication.io.FeedException;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt; * @author Alexander Zagniotov (http://javabeans.asia)&lt;br /&gt; * &lt;br /&gt; */&lt;br /&gt;public class JsonServlet extends HttpServlet {&lt;br /&gt;&lt;br /&gt;private static final long serialVersionUID = 1L;&lt;br /&gt;private static final String BLOG_URL = &lt;br /&gt;		&amp;quot;http://javabeans.asia/rss.xml&amp;quot;;&lt;br /&gt;private static final String CONTENT_TYPE = &lt;br /&gt;			&amp;quot;application/json&amp;quot;;&lt;br /&gt;private FeedFetcherCache feedInfoCache = null;&lt;br /&gt;private FeedFetcher feedFetcher = null;&lt;br /&gt;&lt;br /&gt;public void init(ServletConfig config) &lt;br /&gt;			throws ServletException {&lt;br /&gt;	super.init(config);&lt;br /&gt;&lt;br /&gt;	feedInfoCache = &lt;br /&gt;		HashMapFeedInfoCache.getInstance();&lt;br /&gt;	feedFetcher = &lt;br /&gt;		new HttpURLFeedFetcher(feedInfoCache);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void doGet(HttpServletRequest request, &lt;br /&gt;			HttpServletResponse response)&lt;br /&gt;		throws ServletException, IOException {&lt;br /&gt;&lt;br /&gt;	SyndFeed feed = this.feedFethcer(BLOG_URL);&lt;br /&gt;&lt;br /&gt;  if (feed != null) {&lt;br /&gt;	String json = this.feedToJSON(feed);&lt;br /&gt;	response.setContentType(CONTENT_TYPE);&lt;br /&gt;	response.setHeader(&amp;quot;Cache-Control&amp;quot;, &amp;quot;no-cache&amp;quot;);&lt;br /&gt;	response.getWriter().write(json);&lt;br /&gt;  } &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private SyndFeed feedFethcer(String url) {&lt;br /&gt;	SyndFeed feed = null;&lt;br /&gt;	try {&lt;br /&gt;		feed = feedFetcher.retrieveFeed(&lt;br /&gt;		new URL(BLOG_URL));&lt;br /&gt;	} catch (IllegalArgumentException e) {&lt;br /&gt;		e.printStackTrace();&lt;br /&gt;	} catch (FeedException e) {&lt;br /&gt;		e.printStackTrace();&lt;br /&gt;	} catch (FetcherException e) {&lt;br /&gt;		e.printStackTrace();&lt;br /&gt;	} catch (MalformedURLException e) {&lt;br /&gt;		e.printStackTrace();&lt;br /&gt;	} catch (IOException e) {&lt;br /&gt;		e.printStackTrace();&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	return feed;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private String feedToJSON(SyndFeed feed) {&lt;br /&gt;&lt;br /&gt;	JSONObject jsonObj = new JSONObject();&lt;br /&gt;	JSONArray jsonEntryTitles = new JSONArray();&lt;br /&gt;&lt;br /&gt;	jsonObj.put(&amp;quot;blogtitle&amp;quot;, feed.getTitle());&lt;br /&gt;	jsonObj.put(&amp;quot;blogdescription&amp;quot;, feed.getDescription());&lt;br /&gt;	jsonObj.put(&amp;quot;bloglanguage&amp;quot;, feed.getLanguage());&lt;br /&gt;	jsonObj.put(&amp;quot;bloglink&amp;quot;, feed.getLink());&lt;br /&gt;	jsonObj.put(&amp;quot;author&amp;quot;, feed.getCopyright());&lt;br /&gt;&lt;br /&gt;	List&amp;lt;?&amp;gt; feedEntries = feed.getEntries();&lt;br /&gt;&lt;br /&gt;	for (Object c : feedEntries) {&lt;br /&gt;	     SyndEntry syndicateEntry = (SyndEntry) c;&lt;br /&gt;	     jsonEntryTitles.put(syndicateEntry.getTitle());&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	jsonObj.put(&amp;quot;blogentrytitles&amp;quot;, jsonEntryTitles);&lt;br /&gt;	return jsonObj.toString();&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
As you can see it is very easy to construct JSON objects and arrays on the server side and pass them to the client. For the purpose of this example I am getting my data from RSS feed, but the data can also be coming from DB etc. &lt;br /&gt;
&lt;br /&gt;
The following is my client implementation. The client queries the servlet using AJAX call. When an AJAX call returns a response from the servlet in a form of JSON object, the object data is formatted and information about the RSS feed is presented to the client:&lt;br /&gt;
&lt;pre class=&#034;java&#034; name=&#034;code&#034;&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;title&amp;gt;Java Beans dot Asia&amp;lt;/title&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script language=&amp;quot;JavaScript&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;		&lt;br /&gt;	var httpRequest = null;&lt;br /&gt;	&lt;br /&gt;function getDescriptionAsJSON() {&lt;br /&gt;&lt;br /&gt;	var description = &lt;br /&gt;		document.getElementById(&#039;description&#039;);&lt;br /&gt;	description.innerHTML = &amp;quot;Loading, please wait ...&amp;quot;;&lt;br /&gt;&lt;br /&gt;	var url = &amp;quot;http://localhost:8080/json/json&amp;quot;;&lt;br /&gt;	if(window.XMLHttpRequest){&lt;br /&gt;		httpRequest = new XMLHttpRequest();&lt;br /&gt;	}&lt;br /&gt;	else if(window.ActiveXObject){&lt;br /&gt;		httpRequest = &lt;br /&gt;			new ActiveXObject(&amp;quot;Microsoft.XMLHTTP&amp;quot;);&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	httpRequest.open(&amp;quot;GET&amp;quot;, url, true);&lt;br /&gt;	httpRequest.onreadystatechange = handler;&lt;br /&gt;	httpRequest.send(null);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function handler() {&lt;br /&gt;	if (httpRequest.readyState == 4) {&lt;br /&gt;		if (httpRequest.status == 200) {&lt;br /&gt;		    processJSON(httpRequest.responseText);&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function processJSON(jsonObjectString) {&lt;br /&gt;&lt;br /&gt;	var description = &lt;br /&gt;		document.getElementById(&#039;description&#039;);&lt;br /&gt;	&lt;br /&gt;      //Since JSON is a subset of JavaScript, I am using &lt;br /&gt;      //JavaScript&#039;s own compiler to parse JSON in one line!&lt;br /&gt;      var jsonObject = eval(&#039;(&#039; + jsonObjectString + &#039;)&#039;)&lt;br /&gt;&lt;br /&gt;	var text = &amp;quot;&amp;quot;;&lt;br /&gt;	&lt;br /&gt;	text += &amp;quot;Author: &amp;quot; + jsonObject.author + &amp;quot;&amp;lt; br /&amp;gt;&amp;quot;;&lt;br /&gt;	text += &amp;quot;Blog Name: &amp;quot; + &lt;br /&gt;		jsonObject.blogtitle + &amp;quot;&amp;lt; br /&amp;gt;&amp;quot;;&lt;br /&gt;	text += &amp;quot;Blog URL: &amp;quot; + &lt;br /&gt;		jsonObject.bloglink + &amp;quot;&amp;lt; br /&amp;gt;&amp;quot;;&lt;br /&gt;	text += &amp;quot;Blog Description: &amp;quot; + &lt;br /&gt;		jsonObject.blogdescription + &amp;quot;&amp;lt; br /&amp;gt;&amp;quot;;&lt;br /&gt;	text += &amp;quot;Blog Language: &amp;quot; + &lt;br /&gt;		jsonObject.bloglanguage + &amp;quot;&amp;lt; br /&amp;gt;&amp;quot;;&lt;br /&gt;	&lt;br /&gt;	description.innerHTML = text;&lt;br /&gt;	var entries = &amp;quot;Last &amp;quot; + &lt;br /&gt;                  jsonObject.blogentrytitles.length &lt;br /&gt;	+ &amp;quot; blog entries are:\n\n&amp;quot;;&lt;br /&gt;&lt;br /&gt;	for (var index = 0; &lt;br /&gt;		index &amp;lt; jsonObject.blogentrytitles.length; &lt;br /&gt;							index ++) {&lt;br /&gt;		entries += (index + 1) + &amp;quot;: &amp;quot; + &lt;br /&gt;			jsonObject.blogentrytitles[index] + &amp;quot;\n&amp;quot;;&lt;br /&gt;	} &lt;br /&gt;	alert(entries);&lt;br /&gt;}&lt;br /&gt;	&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;lt;img src=&amp;quot;images/javabeansmugshot_120x120.jpg&amp;quot; border=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt; br /&amp;gt;&lt;br /&gt;&amp;lt; br /&amp;gt;&lt;br /&gt;&amp;lt;div id=&amp;quot;description&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt; br /&amp;gt;&lt;br /&gt;&amp;lt; br /&amp;gt;&lt;br /&gt;&amp;lt;a href=&amp;quot;javascript:void(0)&amp;quot; &lt;br /&gt;             onclick=&amp;quot;return getDescriptionAsJSON();&amp;quot;&amp;gt;&lt;br /&gt;Click to get description!&amp;lt;/a&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;
As you could see, JSON data can be easily parsed on the client side with the help of Java script &lt;em&gt;eval()&lt;/em&gt; function. To remind - JSON is a subset of Java script, therefore&lt;em&gt; eval()&lt;/em&gt; will produce a valid object. &lt;br /&gt;
&lt;br /&gt;
Keep in mind, that there is a need for extra care when using &lt;em&gt;eval&lt;/em&gt;. The problem is that &lt;em&gt;eval&lt;/em&gt; will compile and execute Java script code that coming back from the response. This could cause a security risk if the response data is coming from an untrusted source.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it. I hope this example was clear and helpful :)&lt;br /&gt;
&lt;a href=&#034;http://javabeans.asia/files/src/json_servlets_ajax_war.zip&#034; title=&#034;WAR archive&#034;&gt; &lt;/a&gt;&lt;a href=&#034;http://javabeans.asia/files/src/json_servlets_ajax_war.zip&#034; title=&#034;WAR archive&#034;&gt; &lt;/a&gt;&lt;br /&gt;
Please note that this example was tested by me and its working fine. The source code as mentioned previously is included  as Eclipse project. You can simply create a new Java project from the existing Ant build.xml file. &lt;br /&gt;
&lt;br /&gt;
Comments/flames are appreciated :)&lt;br /&gt;
&lt;br /&gt;
Cheers&lt;br /&gt;
&lt;a href=&#034;http://javabeans.asia/files/src/json_servlets_ajax_war.zip&#034; title=&#034;WAR archive&#034;&gt; &lt;/a&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;t=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;t=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;i&gt;There are no related posts for this blog entry&lt;/i&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          In this article I would like to show how JSON (JavaScript Object Notation) and Java servlet can be used together in a little AJAX (Asynchronous JavaScript and XML) application.   To give brief description to those who are not closely familiar with JSON -  JSON is a lightweight syntax for representing data, which ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;t=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;title=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html&amp;amp;t=Redefining web applications with AJAX, Servlets and JSON&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <enclosure url="http://javabeans.asia/files/src/json_servlets_ajax_src.zip" length="471648" type="application/zip;charset=ISO-8859-1" />
    <category>ajax</category>
    <category>java</category>
    <category>json</category>
    <category>servlets</category>
    <category>xml</category>
    <category>javascript</category>
    <comments>http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2009/09/13/redefining_web_applications_with_ajax_servlets_and_json.html</guid>
    <pubDate>Sun, 13 Sep 2009 04:00:00 GMT</pubDate>
  </item>
  <item>
    <title>How to prevent iFrame breakaway</title>
    <link>http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html</link>
	 <description>
        Few days ago I was searching for a solution to the problem I&#039;ve encountered - I needed to prevent a third party page to break out of iframe inside a web page of my web application. For people who are not closely familiar with JavaScript, the following JS snippet will make it more clear how page can break out of iframe: &lt;br /&gt;
&lt;pre class=&#034;codeSample&#034;&gt;  if (top.location.href != self.location.href)&lt;br /&gt;     top.location.href = self.location.href; &lt;br /&gt;&lt;/pre&gt;
If the current page is not the parent window - become the parent window. &lt;br /&gt;
&lt;br /&gt;
I needed to implement something on my end, that would block or prevent the above script or similar to it from executing. I&#039;ve spent several hours browsing the Net, talking to people on IRC and simply playing trial and error. &lt;br /&gt;
&lt;br /&gt;
After some time, I understood that I wont be able to find a solution to my problem, simply because there is none unfortunately. But, having said that, I have some findings to share:&lt;br /&gt;
&lt;ol&gt;
    &lt;li&gt;There is iframe &lt;em&gt;security &lt;/em&gt;attribute which only works on IE. Setting this attribute to security=&amp;quot;restricted&amp;quot;, will prevent iframe to break out. Its always &amp;quot;nice&amp;quot; to see that MS have few tricks up their sleeve :). Also, on one of the forums, someone mentioned that the same attribute will work under Opera as well as under IE. I personally haven&#039;t tested it my self under Opera, I can just say that it works for IE and not FF.&lt;/li&gt;
    &lt;li&gt;To make use of &lt;em&gt;window.onbeforeunload&lt;/em&gt; event and prompt user with a dialog that requires user&#039;s input if he agrees to navigate away from the current page. If user disagrees (clicks &amp;quot;cancel&amp;quot;), he will remain on the current page. So here in a sense iframe breakaway was canceled. By the way, there is no way to suppress the dialog prompt and make event from clicking &amp;quot;cancel&amp;quot; default.&lt;/li&gt;
    &lt;li&gt;To grab the content of third party page using &lt;a target=&#034;_blank&#034; title=&#034;http://au.php.net/curl&#034; href=&#034;http://au.php.net/curl&#034;&gt;PHP Curl&lt;/a&gt; lib and to create your own placeholder page for that content. Then the placeholder page can be put inside iframe. The page or the grabbed content will not attempt to breakout, but any request submitted to the placeholder page (hyper link or button click on the grabbed content) will cause page to unload.&lt;br /&gt;
    &lt;/li&gt;
&lt;/ol&gt;
Also, while researching, I came across this &lt;a target=&#034;_blank&#034; title=&#034;Preventing Frame Busting and Click Jacking (UI Redressing)&#034; href=&#034;http://coderrr.wordpress.com/2009/02/13/preventing-frame-busting-and-click-jacking-ui-redressing/&#034;&gt;post&lt;/a&gt; that talks about preventing iframe breakaway and click jacking with the help of 204 header response code.&lt;br /&gt;
&lt;br /&gt;
After all that, my conclusion is:&lt;br /&gt;
If the page inside iframe is not yours, in other words it is a page hosted under another domain, its not possible actually to stop a page from unloading. Having something like that,&amp;nbsp; would allow malicious sites to &amp;quot;trap&amp;quot; a user indefinitely. &lt;br /&gt;
&lt;br /&gt;
I would love to hear any other suggestions regarding iframe breakout you may have dear readers.&lt;br /&gt;
&lt;br /&gt;
Cheers&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;t=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;t=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&#034; rel=&#034;bookmark&#034; title=&#034;Detecting an Internet connection with Javascript&#034;&gt;Detecting an Internet connection with Javascript&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          Few days ago I was searching for a solution to the problem I&#039;ve encountered - I needed to prevent a third party page to break out of iframe inside a web page of my web application. For people who are not closely familiar with JavaScript, the following JS snippet will make it more clear how page can break out of ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;t=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;title=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&amp;amp;t=How to prevent iFrame breakaway&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>design patterns</category>
    <category>javascript</category>
    <comments>http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html</guid>
    <pubDate>Sun, 29 Mar 2009 06:37:00 GMT</pubDate>
  </item>
  <item>
    <title>Detecting an Internet connection with Javascript</title>
    <link>http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html</link>
	 <description>
        The other day I was developing small client-server application where I needed to check using Javascript on the client&#039;s side whether active Internet connection exists, before submitting request to the server.&lt;br /&gt;
&lt;br /&gt;
Javascript does not allow you to do ping, and even so many websites protect against ping requests (ICMP echo), so I had to come up with some alternatives.&lt;br /&gt;
&lt;br /&gt;
One of the nice solutions that I have found is to create an Image object and to specify as image source, URL to an image located on a remote server. Then to test, if the newly created Image object has height or width greater than zero.&lt;br /&gt;
&lt;br /&gt;
If it is greater, what it means is that there is active Internet connection, since it was possible to create Image object using image or icon located on a remote server.&lt;br /&gt;
&lt;br /&gt;
The downside here is that path to the image or image filename may change in the future on the target remote server, and as a result of that your Javascript function will stop working. &lt;br /&gt;
&lt;br /&gt;
While thinking what image should I link to, I decided to use Google&#039;s favicon. I tend to think that the favicon is not something that is going to change very often. I also considered to use Goggle logo, but favicon is much smaller in size.&lt;br /&gt;
(Another thing worth remembering is to allow some time to retrieve the remote image, which is another reason why I went for the favicon).&lt;br /&gt;
&lt;br /&gt;
The solution is:&lt;br /&gt;
&lt;pre name=&#034;code&#034; class=&#034;java:firstline[1]&#034;&gt;function testConnection() {&lt;br /&gt;   var googleFavIcon = new Image();&lt;br /&gt;   googleFavIcon.src = &lt;br /&gt;               &amp;quot;http://www.google.com/favicon.ico&amp;quot;;&lt;br /&gt;&lt;br /&gt;   if(googleFavIcon.height&amp;gt;0)  {&lt;br /&gt;       //do something&lt;br /&gt;    } &lt;br /&gt;    else {&lt;br /&gt;      //warn user&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;
Just keep in mind, that the remote image is cached once you got it. If you decide to test connection again, you have to make sure that you are not using the cached image, but trying to retrieve it again from the remote server. To prevent caching, you can add some random parameter to the URL:
&lt;pre class=&#034;codeSample&#034;&gt;http://www.google.com/favicon.ico?param=[random-value]&lt;/pre&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;t=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;t=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/03/29/how_to_prevent_iframe_breakaway.html&#034; rel=&#034;bookmark&#034; title=&#034;How to prevent iFrame breakaway&#034;&gt;How to prevent iFrame breakaway&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          The other day I was developing small client-server application where I needed to check using Javascript on the client&#039;s side whether active Internet connection exists, before submitting request to the server.  Javascript does not allow you to do ping, and even so many websites protect against ping requests (ICMP ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;t=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;title=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html&amp;amp;t=Detecting an Internet connection with Javascript&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>javascript</category>
    <comments>http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2009/01/24/detecting_an_internet_connection_with_javascript.html</guid>
    <pubDate>Sat, 24 Jan 2009 07:26:00 GMT</pubDate>
  </item>
  </channel>
</rss>
