<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7900835119661228409</id><updated>2024-10-01T21:23:13.975+05:30</updated><category term="Back To School"/><category term="Fine Tune JavaScript"/><category term="jQuery: By Examples"/><category term="javascript"/><category term="performance"/><category term="Tips and Tricks"/><category term="What&#39;s New"/><category term="Application Server FAQs"/><category term="Articles"/><category term="EJB FAQs"/><category term="Introduction"/><title type='text'>My Error Log</title><subtitle type='html'>Every day we encounter lot of errors while compiling or running applications. The most common is NullPointerException. So when you see this sort of error, what is your approach? Yes &quot;APPROACH&quot;! This is the word I like to share with you people.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-4337659621520635072</id><published>2013-07-17T13:34:00.000+05:30</published><updated>2013-07-17T13:42:28.281+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Fine Tune JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="performance"/><title type='text'>Fine Tune JavaScript - Improve Performance with Local Variables</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot;&gt;
We all know literal values and local variables can be accessed very quickly, whereas array items and object members take longer. But what is a reason behind it? In this article I will talk about how you can improve performance of your existing code with the use of local variables wisely.&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
Let&#39;s start with a simple example -&lt;/div&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;function updateClass(){&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;var divList = document.getElementsByTagName(&quot;div&quot;);&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;for(var counter = 0; counter&amp;lt;divList.length; counter++){&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;divList[counter].className = document.body.className;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
 }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot;&gt;
Before improving the performance of the function let&#39;s see what all artifacts/internal objects are created when the function created and executed. When the function is created, it&#39;s [[Scope]] property is initialized with a collection of global variables. More info about Scope Chain is available in the earlier post - &lt;a href=&quot;http://myerrorslog.blogspot.in/2013/07/javascript-jargon-scope-chain-execution.html&quot; target=&quot;_blank&quot;&gt;JavaScript&amp;nbsp;Jargon&amp;nbsp;-&amp;nbsp;Scope&amp;nbsp;Chain,&amp;nbsp;Execution&amp;nbsp;Context&amp;nbsp;and&amp;nbsp;Activation&amp;nbsp;Object&lt;/a&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
Some of the global variables which are available in the [[Scope]] object are -&lt;/div&gt;
&lt;ul dir=&quot;ltr&quot;&gt;
&lt;li&gt;
  &lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;
  &lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;window&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;
  &lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;document&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;
  &lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;updateClass&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div dir=&quot;ltr&quot;&gt;
When the function is executed, a new internal object - Execution Context, is created which has it&#39;s own scope chain. This scope chain is initialized with the objects present in the scope chain which was created when the function itself was created. Once the initialization is over, another internal object - Activation object, is created and pushed on top of the execution object&#39;s scope chain. The activation object acts as the variable object for this execution and contains entries for all local variables, named arguments, the &lt;span style=&quot;color: #38761d;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;arguments&lt;/span&gt; &lt;/b&gt;&lt;/span&gt;collection, and &lt;span style=&quot;color: #38761d;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;this&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;. In this case activation object will have -&lt;/div&gt;
&lt;ul dir=&quot;ltr&quot;&gt;
&lt;li&gt;
  &lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;
  &lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;divList&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;
  &lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;counter&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;
  &lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;arguments[] &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;- it null in this case as there are no arguments passed to the function&lt;/li&gt;
&lt;/ul&gt;
&lt;div dir=&quot;ltr&quot;&gt;
The scope chain of the execution context object now will have two entries - Activation Object and Global Object.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
Each time a variable is encountered during the function’s execution, the process of &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;Identifier Resolution&lt;/b&gt;&lt;/span&gt; takes place to determine where to retrieve or store the data. It first starts with searching the variable in the execution object&#39;s scope chain and goes all the way down to the global object, if it is not found in the first place. It is this search process that affects performance. The &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;deeper into the execution context’s scope chain&lt;/b&gt;&lt;/span&gt; an identifier exists, the &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;slower it is to access&lt;/b&gt;&lt;/span&gt; for both reads and writes. Since local variables are always available in the activation object, therefor their access is always fastest as compared to the global variable which are available in the end of the chain.&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
A good rule of thumb is to &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;always store out-of-scope values in local variables if they are used more than once within a function&lt;/b&gt;&lt;/span&gt;. In the function above, the &lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;document &lt;/span&gt;object is being accessed multiple time, Since the &lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;b&gt;document&lt;/b&gt;&lt;/span&gt; &lt;/span&gt;object is a global variable, therefore every time it is being accessed you have to pay the performance penalty. Based on this information here is the &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;improved version of the function&lt;/b&gt;&lt;/span&gt; -&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;function improvedUpdateClass(){&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;var docObject = document;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;var divList = docObject.getElementsByTagName(&quot;div&quot;);&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;var className = docObject.body.className;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;var divCount = divList.length;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;for(var counter = 0; counter&amp;lt;divCount; counter++){&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;divList[counter].className = className;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
 }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
In this improved version, instead of accessing the document object&amp;nbsp; multiple times, it&#39;s reference is being stored in a local variable - &lt;span style=&quot;color: #38761d;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;docObject&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;, which is being accessed in rest of the function. Also we have created a local variable for storing body&#39;s class name - &lt;span style=&quot;color: #38761d;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;className&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;, which is again improves performance.&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/4337659621520635072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/4337659621520635072' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/4337659621520635072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/4337659621520635072'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2013/07/fine-tune-javascript-improve.html' title='Fine Tune JavaScript - Improve Performance with Local Variables'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-617573329992260966</id><published>2013-07-16T19:01:00.003+05:30</published><updated>2013-07-17T13:45:37.486+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Fine Tune JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="performance"/><title type='text'>JavaScript Jargon - Scope Chain, Execution Context and Activation Object</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot;&gt;
In JavaScript every function is represented as an object - an instance of the JavaScript Function. Like any other object, it also has some properties which can be accessed programmatically and&amp;nbsp; few which are used only by the JavaScript engines. One of the properties is&lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;b&gt; [[Scope]]&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; which is available only for the engines.&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
This internal [[Scope]] property is a collection of objects which represents the scope/environment in with the function is defined. The collection of objects, which determines the data which the function can access, is known as function&#39;s &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;Scope Chain&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;. Each object in the Scope Chain is called as&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt; Variable Object&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;. A Variable Object holds the variables, in the form of key-value pair, which a function can access.&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
Let&#39;s understand it better with the following example -&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;function multiply(arg1, arg2){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var result = arg1 * arg2;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return result;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;color: darkgreen;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
In this case as soon as the function is created, it&#39;s Scope Chain is initialized with a variable object - &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;Global Object&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;. A Global Object is a collection of data, available outside the scope of the function, which the function can access, like - window, document, navigator etc..&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
At the time of function execution, an internal object&amp;nbsp; - &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;Execution Context&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;, is created. Execution Context represents the environment in which the function is executed. Once the execution is completed, this object is destroyed. Execution Context is created per execution. Therefore if the same function is executed multiple times, multiple Execution Context objects are created.&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
Execution Context object also has it&#39;s own Scope Chain object which is initialized with the data present in the function&#39;s&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt; [[Scope]]&lt;/span&gt; object. Later a new object - &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;Activation Object&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;, is created and pushed on top of the Global Object in the Execution Context&#39;s Scope Chain.&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
The internal Activation Object holds data specific to the function - local variable/s, named argument/s, argument[] and this. Again this object is destroyed once the function execution is completed. .&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/617573329992260966/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/617573329992260966' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/617573329992260966'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/617573329992260966'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2013/07/javascript-jargon-scope-chain-execution.html' title='JavaScript Jargon - Scope Chain, Execution Context and Activation Object'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-5155780094176953929</id><published>2013-07-11T10:59:00.001+05:30</published><updated>2013-07-11T10:59:25.794+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Fine Tune JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="performance"/><title type='text'>Fine Tune JavaScript - On Demand Script loading</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 Dynamically loading external scripts is one of the techniques used to write &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;non-blocking JavaScript&lt;/strong&gt;&lt;/span&gt; code.&amp;nbsp; It is a three step process &amp;ndash;&lt;/p&gt;
&lt;ul dir=&quot;ltr&quot;&gt;
 &lt;li&gt;
  Create an element for the &amp;lt;script&amp;gt; tag.&lt;/li&gt;
 &lt;li&gt;
  Set the source of the &amp;lt;script&amp;gt; element as the location of the external script file.&lt;/li&gt;
 &lt;li&gt;
  Append the &amp;lt;script&amp;gt; element to either of the two - &amp;lt;body&amp;gt; or &amp;lt;head&amp;gt;, tag.&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 In this example, we try to load the external script dynamically &amp;ndash;&lt;br /&gt;
 &lt;br /&gt;
 &amp;nbsp;&lt;span style=&quot;color:#006400;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt; var scriptObj = document.createElement(&amp;#39;script&amp;#39;);&lt;br /&gt;
 &amp;nbsp; scriptObj.src = &amp;#39;external-script.js&amp;#39;;&lt;br /&gt;
 &amp;nbsp; document.getElementsByTagName(&amp;quot;head&amp;quot;)[0].appendChild(scriptObj);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
 &lt;br /&gt;
 This new &amp;lt;script&amp;gt; element loads the source file external-script.js. The file&lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt; begins downloading as soon as the element is added to the page&lt;/strong&gt;&lt;/span&gt;. The important thing about this technique is that the file is downloaded and executed &lt;strong&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;without blocking other page processes&lt;/span&gt;&lt;/strong&gt;, regardless of where the download is initiated. &amp;nbsp;&lt;br /&gt;
 &lt;br /&gt;
 You can also &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;attach event handlers&lt;/strong&gt;&lt;/span&gt; to take action when the script is downloaded completely. But there is slight &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;different between the event which is being fired in case of IE and rest of the browsers&lt;/strong&gt;&lt;/span&gt; (Firefox, Opera, Chrome, Safari ). Firefox, Opera, Chrome, and Safari 3+ all fire a &lt;span style=&quot;color:#008000;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;load&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt; event when the src of a&lt;br /&gt;
 &amp;lt;script&amp;gt; element has been retrieved. In case of IE, &lt;span style=&quot;color:#006400;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;readystatechange&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt; event is triggered.&lt;br /&gt;
 &lt;br /&gt;
 This example takes care of both the use-case &amp;ndash;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 &lt;span style=&quot;color:#006400;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var script = document.createElement(&amp;quot;script&amp;quot;)&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;script.type = &amp;quot;text/javascript&amp;quot;;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//Internet Explorer&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (script.readyState){&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;script.onreadystatechange = function(){&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (script.readyState == &amp;quot;loaded&amp;quot; || script.readyState == &amp;quot;complete&amp;quot;){&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;script.onreadystatechange = null;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;alert(&amp;quot;Script loaded.&amp;quot;);&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;};&lt;br /&gt;
 &lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;} else{&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//Firefox, Opera, Chrome, Safari 3+&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;script.onload = function(){&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;alert(&amp;quot;Script loaded!&amp;quot;);&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;};&lt;br /&gt;
 &lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;script.src = &amp;quot;file1.js&amp;quot;;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;document.getElementsByTagName(&amp;quot;head&amp;quot;)[0].appendChild(script);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 &amp;nbsp;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 &lt;br /&gt;
 &amp;nbsp;&lt;/p&gt;

&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/5155780094176953929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/5155780094176953929' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/5155780094176953929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/5155780094176953929'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2013/07/fine-tune-javascript-on-demand-script.html' title='Fine Tune JavaScript - On Demand Script loading'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-774705050033208054</id><published>2013-07-11T10:56:00.002+05:30</published><updated>2013-07-11T10:57:22.514+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Fine Tune JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="performance"/><title type='text'>Fine Tune JavaScript - Defer Script execution</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 Deferring execution of scripts is one of the techniques used to write &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;non-blocking JavaScript&lt;/strong&gt;&lt;/span&gt; code.&amp;nbsp; HTML provides the &lt;span style=&quot;font-size:14px;&quot;&gt;&lt;span style=&quot;color: rgb(0, 100, 0);&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;&lt;strong&gt;defer&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; attribute for the &amp;lt;script&amp;gt; tag. When present, it specifies that the script is executed when the page has finished parsing/loading. &amp;nbsp;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 Note: &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;The &lt;/strong&gt;&lt;/span&gt;&lt;span style=&quot;color:#006400;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;defer&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt; attribute is only for external scripts&lt;/strong&gt;&lt;/span&gt; (should only be used if the &lt;span style=&quot;color:#006400;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;&lt;strong&gt;src&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt; attribute is present).&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 &lt;span style=&quot;font-family:arial,helvetica,sans-serif;&quot;&gt;For example this case the script will not run until after the page has loaded:&lt;/span&gt;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 &amp;nbsp;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 &amp;nbsp; &lt;span style=&quot;color:#006400;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;&amp;lt;script src=&amp;quot;demo_defer.js&amp;quot; &lt;span style=&quot;font-size:14px;&quot;&gt;&lt;strong&gt;defer&lt;/strong&gt;&lt;/span&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 &amp;nbsp;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 &lt;span style=&quot;font-size:12px;&quot;&gt;&lt;span style=&quot;font-family: arial,helvetica,sans-serif;&quot;&gt;As soon as the &amp;lt;script&amp;gt; tag is parsed, JavaScript file will begin downloading, but the code will not be executed until the DOM has been completely loaded (before the onload event handler is called). It &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;doesn&amp;rsquo;t block&lt;/strong&gt;&lt;/span&gt; the browser&amp;rsquo;s other processes, and so these files can be downloaded in parallel with others on the page.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 &amp;nbsp;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 &amp;nbsp;&lt;/p&gt;

&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/774705050033208054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/774705050033208054' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/774705050033208054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/774705050033208054'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2013/07/deferring-execution-of-scripts-is-one.html' title='Fine Tune JavaScript - Defer Script execution'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-9221257813919803909</id><published>2013-07-11T10:51:00.001+05:30</published><updated>2013-07-11T10:53:42.627+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Fine Tune JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="performance"/><title type='text'>Fine Tune JavaScript - Placement of SCRIPTs</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 We have been writing JavaScript code from ages. But have you ever think of &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;OPTIMIZING&lt;/strong&gt;&lt;/span&gt; it? How many of you know about the &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;Design Patterns for JavaScript&lt;/strong&gt;&lt;/span&gt;? &amp;quot; WHAT!!! Design Patterns for JavaScript? Do they really exists?&amp;quot;. Yes that&amp;#39;s what might have come in your mind. Well to be very honest, most of the UI developers, never focus on the performance of the JavaScript.&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 Despite advancements in core JavaScript execution time, there are still aspects of JavaScript that the new age JavaScript engines don&amp;rsquo;t handle.In this and next few articles I will focus on how to improve performance of the JavaScript code we write. I will share techniques and approaches which will address different aspects of JavaScript, including execution time, downloading, DOM interaction, page life cycle, and more.&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 This article talks about &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;improving page loading and execution time&lt;/strong&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 Let&amp;#39;s start with a simple example -&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 &lt;span style=&quot;color:#006400;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;&amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;head&amp;gt;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;title&amp;gt;Simple Script &amp;lt;/title&amp;gt;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;script src=&amp;quot;file1.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;script src=&amp;quot;file2.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;link rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; href=&amp;quot;styles.css&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/head&amp;gt;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;body&amp;gt;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;p&amp;gt;Hello world!&amp;lt;/p&amp;gt;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 Can you guess &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;what&amp;#39;s wrong&lt;/strong&gt;&lt;/span&gt; with this code? Well the answer is - &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;inefficient script positioning&lt;/strong&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 Usually we all keep all the &amp;lt;script&amp;gt; tags that are used to load external JavaScript files along with &amp;lt;link&amp;gt; tags to load external CSS files and other meta information about the page in the &amp;lt;head&amp;gt; tag. The theory was that it&amp;rsquo;s best to keep as many style and behavior dependencies together, loading them first so that the page will come in looking and behaving correctly.&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 Today most browsers use a &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;single process&lt;/strong&gt;&lt;/span&gt; for both user interface (UI) updates and JavaScript execution, so only one can happen at any given moment in time. The longer&lt;br /&gt;
 JavaScript takes to execute, the longer it takes before the browser is free to respond to user input. this means that the very presence of a &amp;lt;script&amp;gt; tag is enough to make&lt;br /&gt;
 the page wait for the script to be parsed and executed. Whether the actual JavaScript code is inline with the tag or included in an external file is irrelevant; the page download&lt;br /&gt;
 and rendering must stop and wait for the script to complete before proceeding. This is a necessary part of the page&amp;rsquo;s life cycle because the script may cause changes to the page while executing.&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 In the example above each&lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt; &amp;lt;script&amp;gt; tag blocks the page from continuing to render &lt;/strong&gt;&lt;/span&gt;until it has fully downloaded and executed the JavaScript code, the overall performance of this page will suffer. Keep in mind that browsers don&amp;rsquo;t start rendering anything on the page until the opening &amp;lt;body&amp;gt; tag is encountered. Putting scripts at the top of the page in this way typically leads to a noticeable delay, often in the form of a blank white page, before the user can even begin reading or otherwise interacting with the page.&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 Although new age browsers support &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;parallel downloading of the external JavaScript&lt;/strong&gt;&lt;/span&gt; files but it still blocks downloading of other resources, such as Images. And even though downloading a script doesn&amp;rsquo;t block other scripts from downloading, the page must still wait for the JavaScript code to be downloaded and executed before continuing.&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 So what&amp;#39;s the &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;solution &lt;/strong&gt;&lt;/span&gt;to this problem? Well the best solution to this problem is to &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;place all &amp;lt;script&amp;gt; tags as close to the bottom of the &amp;lt;body&amp;gt; tag&lt;/strong&gt;&lt;/span&gt; as possible so as not&lt;br /&gt;
 to affect the download of the entire page -&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 &lt;span style=&quot;color:#006400;&quot;&gt;&lt;span style=&quot;font-family: courier new,courier,monospace;&quot;&gt;&amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;head&amp;gt;&lt;br /&gt;
 &amp;lt;title&amp;gt;Simple Script&amp;lt;/title&amp;gt;&lt;br /&gt;
 &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; href=&amp;quot;styles.css&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;/head&amp;gt;&lt;br /&gt;
 &amp;lt;body&amp;gt;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;p&amp;gt;Hello world!&amp;lt;/p&amp;gt;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;script src=&amp;quot;file1.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
 &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;script src=&amp;quot;file2.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
 &amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 In this case even though the script downloads will block one another, the rest of the page has already been downloaded and displayed to the user so that the entire page isn&amp;rsquo;t perceived as slow.&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 That&amp;#39;s the &lt;span style=&quot;color:#ff0000;&quot;&gt;&lt;strong&gt;first lesson&lt;/strong&gt;&lt;/span&gt; for you!!!&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;
 &amp;nbsp;&lt;/p&gt;

&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/9221257813919803909/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/9221257813919803909' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/9221257813919803909'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/9221257813919803909'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2013/07/we-have-been-writing-javascript-code.html' title='Fine Tune JavaScript - Placement of SCRIPTs'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-2257305097574596621</id><published>2010-09-21T09:52:00.023+05:30</published><updated>2010-09-22T13:42:00.508+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tips and Tricks"/><title type='text'>Syntax Highlighter - Easy way to insert code to your Blog</title><content type='html'>Are you unable to NEATLY insert html/code in your blog? Yes I am talking about NEATLY injecting code to your blogger’s post. There are so many ways through which you can insert the code, but displaying it in a CLEAN and NEAT way is a common problem. &lt;br /&gt;
Solution to your problem is – SyntaxHighlighter. SyntaxHighlighter is designed to enhance the appearance for your injected code so it becomes more presentable and readable. Follow the simple steps listed below to HIGHLIGHT your code:&lt;br /&gt;
&lt;br /&gt;
Download the latest version (2.1.364) of SyntaxHighlighter from &lt;a href=&quot;http://www.ibizeye.com/upload/syntaxhighlighter_2.1.364.zip&quot;&gt;here&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Extract the archive any where on your machine. Since your blogger will require scripts and stylesheets while formatting the injected code, therefore you have to upload the required files to some file hosting server. I am using MyDataNest to host the files. Other option is to use the files directly from the Amazon S3 where all the files are hosted for SyntaxHighlighter. To know more about how to use Amazon S3 hosting server, check out - &lt;a href=&quot;http://alexgorbatchev.com/SyntaxHighlighter/hosting.html &quot;&gt;Hosting details&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
If you are uploading files to your hosting server, then you have to make few changes in shCore.css. In this file location of all the .png files are relative to shCore.css. You need to replace it with the url generated by your hosting server for the .png files. For example:&lt;br /&gt;
&lt;div style=&quot;display:none&quot;&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.mdn.fm/files/203429_cxbgd/shCore.js&quot;&gt;&lt;/script&gt; &lt;br /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.mdn.fm/files/203418_pxjga/shBrushJScript.js&quot;&gt;&lt;/script&gt; &lt;br /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.mdn.fm/files/203407_1hmq9/shBrushBash.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.mdn.fm/files/203409_yhno5/shBrushCpp.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
 @import url(&quot;http://www.mdn.fm/files/203601_zvagb/shCore.css&quot;); 
 @import url(&quot;http://www.mdn.fm/files/203375_cvxdp/shThemeDefault.css&quot;);
&lt;/style&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
 SyntaxHighlighter.all();
 &lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
Code from the original shCore.css:&lt;br /&gt;
&lt;pre class=&quot;brush: jscript;&quot;&gt;.syntaxhighlighter .toolbar .item.viewSource
{
 background-image: url(page_white_code.png) !important;
}
&lt;/pre&gt;&lt;br /&gt;
Replaced with the new URL:&lt;br /&gt;
&lt;pre class=&quot;brush: jscript;&quot;&gt;.syntaxhighlighter .toolbar .item.viewSource
{
 background-image: url(“http://www.mdn.fm/files/203599_tgby9/page_white_code.png”) !important;
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Beauty of SyntaxHighlighter is that it is not limited to styling HTML. It also supports plenty of other languages like:&lt;br /&gt;
&lt;ul style=&quot;margin: 0px&quot;&gt;&lt;li&gt;XML&lt;/li&gt;
&lt;li&gt;PHP&lt;/li&gt;
&lt;li&gt;SQL&lt;/li&gt;
&lt;li&gt;Java&lt;/li&gt;
&lt;li&gt;AppleScript&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
So if you want to style PHP code then use PHP specific script file - shBrushPhp.js&lt;br /&gt;
&lt;br /&gt;
I this example I will be formatting javascript code. Therefore I’ll be using files which are required to format javascript. To format javascript, I need following files:&lt;br /&gt;
Script Files:&lt;br /&gt;
&lt;ul style=&quot;margin: 0px&quot;&gt;&lt;li&gt;shCore.js&lt;/li&gt;
&lt;li&gt;shBrushJScript.js&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Stylesheets:&lt;br /&gt;
&lt;ul style=&quot;margin: 0px&quot;&gt;&lt;li&gt;shCore.css&lt;/li&gt;
&lt;li&gt;shThemeDefault.css&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Insert following piece of code in your blogger’s post before you inject the code to be formatted:&lt;br /&gt;
&lt;pre class=&quot;brush: jscript;&quot;&gt;&amp;lt;div style=&quot;display:none&quot;&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://www.mdn.fm/files/203429_cxbgd/shCore.js&quot;&amp;gt;&amp;lt;/script&amp;gt; 
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://www.mdn.fm/files/203418_pxjga/shBrushJScript.js&quot;&amp;gt;&amp;lt;/script&amp;gt; 
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://www.mdn.fm/files/203407_1hmq9/shBrushBash.js&quot;&amp;gt;&amp;lt;/script&amp;gt; 
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://www.mdn.fm/files/203409_yhno5/shBrushCpp.js&quot;&amp;gt;&amp;lt;/script&amp;gt; 
&amp;lt;style type=&quot;text/css&quot;&amp;gt; 
@import url(&quot;http://www.mdn.fm/files/203601_zvagb/shCore.css&quot;); 
@import url(&quot;http://www.mdn.fm/files/203375_cvxdp/shThemeDefault.css&quot;); 
&amp;lt;/style&amp;gt; 
&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;  
SyntaxHighlighter.all(); 
&amp;lt;/script&amp;gt; 
&amp;lt;/div&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
Now all you have to do is to insert your code between &amp;lt;pre&amp;gt;&amp;lt;/pre&amp;gt; tags. Also you need to specify the type of bursh - language code. For example, to style javascript code, bursh type should be jscript:&lt;br /&gt;
&lt;pre class=&quot;brush: jscript;&quot;&gt;&amp;lt;pre class=&quot;brush: jscript&quot;&amp;gt;
$(&#39;a&#39;).click(function(){
//do something
})
&amp;lt;/pre&amp;gt;
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/2257305097574596621/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/2257305097574596621' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/2257305097574596621'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/2257305097574596621'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2010/09/syntax-highlighter-easy-way-to-insert.html' title='Syntax Highlighter - Easy way to insert code to your Blog'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-2708659665547313566</id><published>2010-06-28T22:18:00.012+05:30</published><updated>2010-06-29T15:47:51.810+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="jQuery: By Examples"/><title type='text'>jQuery By Examples: Load data through Ajax - 2</title><content type='html'>In this example, I am populating a Drop Down list asynchronously through the .load() method. Advantage of loading data through .load() method is that it allows us to specify a portion of the remote document to be inserted. This is achieved with a special syntax for the url parameter. If one or more space characters are included in the string, the portion of the string following the first space is assumed to be a jQuery selector that determines the content to be loaded. Therefore instead of loading the complete document, here I can load specific portion of the document. In this example first I am getting the list of all the Tags available under the Index section of the page. This is achieved through the special URL syntax used in the .load() method. The next setp is to load the data in a temporary &lt;i&gt;div&lt;/i&gt;. Here is the sample data available in the &lt;i&gt;div &lt;/i&gt;element:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&amp;lt;a dir=&#39;ltr&#39; href=&#39;http://myerrorslog.blogspot.com/search/label/Application%20Server%20FAQs&#39;&amp;gt;Application Server FAQsa&amp;gt;&lt;br /&gt;
&amp;lt;span dir=&#39;ltr&#39;&amp;gt;(1)span&amp;gt;&lt;br /&gt;
li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&amp;lt;a dir=&#39;ltr&#39; href=&#39;http://myerrorslog.blogspot.com/search/label/Articles&#39;&amp;gt;Articlesa&amp;gt;&lt;br /&gt;
&amp;lt;span dir=&#39;ltr&#39;&amp;gt;(1)span&amp;gt;&lt;br /&gt;
li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the data is loaded in the &lt;i&gt;div&lt;/i&gt;, I am populating the drop down by creating &lt;i&gt;option &lt;/i&gt;element dynamically. Every &lt;i&gt;option&lt;/i&gt; has following attributes:&lt;br /&gt;
text - text from the &lt;i&gt;a&lt;/i&gt; tag&lt;br /&gt;
value - href from the &lt;i&gt;a&lt;/i&gt; tag&lt;br /&gt;
&lt;br /&gt;
Once all the &lt;i&gt;li&lt;/i&gt; elements are process, the temp &lt;i&gt;div&lt;/i&gt; is removed.&lt;br /&gt;
&lt;br /&gt;
Now when a user, clicks the button to get the posts for the selected Tag, data is loaded again asynchronously through the .load() method. Instead of loading the complete post, I am loading specific part of the post.&lt;br /&gt;
&lt;h4&gt;Demo:&lt;br /&gt;
&lt;/h4&gt;&lt;div id=&#39;LoadPostContainer&#39;&gt;&lt;label for=&#39;LoadPostSelect&#39;&gt;Select a Tag&lt;/label&gt;&lt;br /&gt;
&lt;select id=&#39;LoadPostSelect&#39; name=&#39;LoadPostSelect&#39;&gt;&lt;/select&gt;&lt;br /&gt;
&lt;/br /&gt;&lt;br /&gt;
&lt;input type=&#39;button&#39; id=&#39;LoadPostButton&#39; name=&#39;LoadPostButton&#39; value=&#39;Get Posts&#39;&gt;&lt;/input&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/br /&gt;&lt;br /&gt;
&lt;div id=&quot;LoadPostContent&quot;&gt;&lt;/div&gt;&lt;h4&gt;&lt;a href=&quot;#&quot; id=&quot;link_code_ajaxLoad2&quot; onclick=&quot;return false;&quot;&gt;Click the link to show code fragment&lt;/a&gt;&lt;/h4&gt;&lt;div id=&quot;code_ajaxLoad2&quot; style=&quot;display: none;&quot;&gt;&lt;code&gt;&lt;br /&gt;
&amp;lt;!DOCTYPE HTML &amp;gt;&lt;br /&gt;
&amp;lt;HTML&amp;gt;&lt;br /&gt;
&amp;lt;HEAD&amp;gt;&lt;br /&gt;
&amp;lt;TITLE&amp;gt; Load data from Posts &amp;lt;/TITLE&amp;gt;&lt;br /&gt;
&amp;lt;/HEAD&amp;gt;&lt;br /&gt;
&amp;lt;BODY&amp;gt;&lt;br /&gt;
&amp;lt;div id=&#39;LoadPostContainer&#39;&amp;gt;&lt;br /&gt;
&amp;lt;label for=&#39;LoadPostSelect&#39;&amp;gt;Select a Tag&amp;lt;/label&amp;gt;&lt;br /&gt;
&amp;lt;select id=&#39;LoadPostSelect&#39; name=&#39;LoadPostSelect&#39;&amp;gt;&amp;lt;/select&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;/br /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&#39;button&#39; id=&#39;LoadPostButton&#39; name=&#39;LoadPostButton&#39; value=&#39;Get Posts --&amp;gt;&#39; /&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div id=&quot;LoadPostContent&quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;script type=&#39;text/javascript&#39; src=&#39;http://code.jquery.com/jquery-latest.min.js&#39; &amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script type=&#39;text/javascript&#39;&amp;gt;&lt;br /&gt;
$(function(){&lt;br /&gt;
var dataLoaded = false;&lt;br /&gt;
var selectedHref = &#39;&#39;;&lt;br /&gt;
$(&#39;&amp;lt;div id=&quot;tempCnt&quot; /&amp;gt;&#39;).load(&#39;http://myerrorslog.blogspot.com div[class=&quot;widget-content list-label-widget-content&quot;] li&#39;, &lt;br /&gt;
function(result){&lt;br /&gt;
$(this).children(&#39;li&#39;).each(function(){&lt;br /&gt;
var optionObj = document.createElement(&#39;option&#39;);&lt;br /&gt;
optionObj.value = $(this).children(&#39;a&#39;).attr(&#39;href&#39;);&lt;br /&gt;
optionObj.text = $(this).children(&#39;a&#39;).text();&lt;br /&gt;
var selectObject = document.getElementById(&#39;LoadPostSelect&#39;);&lt;br /&gt;
selectObject.add(optionObj);&lt;br /&gt;
})&lt;br /&gt;
$(&#39;#tempCnt&#39;).remove();//removes temporary div&lt;br /&gt;
dataLoaded = true;&lt;br /&gt;
})//.load()&lt;br /&gt;
&lt;br /&gt;
$(&#39;#LoadPostButton&#39;).click(function(){&lt;br /&gt;
if(dataLoaded){&lt;br /&gt;
$(&#39;#LoadPostSelect&#39;).children(&#39;option&#39;).each(function(){&lt;br /&gt;
if($(this).attr(&#39;selected&#39;)){&lt;br /&gt;
selectedHref = $(this).attr(&#39;value&#39;)        &lt;br /&gt;
}&lt;br /&gt;
})          &lt;br /&gt;
$(&#39;#LoadPostContent&#39;).load(selectedHref + &#39; div[class=&quot;post-outer&quot;]&#39;, &lt;br /&gt;
function(result){    &lt;br /&gt;
//disable all the links     &lt;br /&gt;
$(&#39;#LoadPostContent a&#39;).each(function(){&lt;br /&gt;
$(this).attr(&#39;href&#39;, &#39;#&#39;).attr(&#39;onclick&#39;, &#39;return false;&#39;)&lt;br /&gt;
//alert($(this).html())&lt;br /&gt;
})      &lt;br /&gt;
})//$(&#39;#LoadPostContent&#39;).load&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
})&lt;br /&gt;
&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/BODY&amp;gt;&lt;br /&gt;
&amp;lt;/HTML&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;/div&gt;&lt;style type=&quot;text/css&quot;&gt;
 #LoadPostContent{
  padding: .5em;
  background: #e3e3e3;
  border: 1px solid #bfbfbf;
  display: none
 }
  &lt;/style&gt;&lt;br /&gt;
&lt;script type=&#39;text/javascript&#39; src=&#39;http://code.jquery.com/jquery-latest.min.js&#39; &gt;&lt;/script&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
 $(function(){
 var dataLoaded = false;
 var selectedHref = &#39;&#39;;
 $(&#39;&lt;div id=&quot;tempCnt&quot; /&gt;&#39;).load(&#39;http://myerrorslog.blogspot.com div[class=&quot;widget-content list-label-widget-content&quot;] li&#39;, 
 function(result){
  $(this).children(&#39;li&#39;).each(function(){   
   var optionObj = document.createElement(&#39;option&#39;);
   optionObj.value = $(this).children(&#39;a&#39;).attr(&#39;href&#39;);
   optionObj.text = $(this).children(&#39;a&#39;).text();
   var selectObject = document.getElementById(&#39;LoadPostSelect&#39;);
   try{
   selectObject.add(optionObj, null);
   } catch(err){
  selectObject.add(optionObj);
   }
  })
  $(&#39;#tempCnt&#39;).remove();//removes temporary div
  dataLoaded = true;
 })

 $(&#39;#LoadPostButton&#39;).click(function(){
  if(dataLoaded){
   $(&#39;#LoadPostSelect&#39;).children(&#39;option&#39;).each(function(){
    if($(this).attr(&#39;selected&#39;)){
     selectedHref = $(this).attr(&#39;value&#39;)        
    }
   })          
   $(&#39;#LoadPostContent&#39;).load(selectedHref + &#39; div[class=&quot;post-outer&quot;]&#39;, 
   function(result){    
   $(this).show()
   //disable all the links     
    $(&#39;#LoadPostContent a&#39;).each(function(){
     $(this).attr(&#39;href&#39;, &#39;#&#39;).attr(&#39;onclick&#39;, &#39;return false;&#39;)
     //alert($(this).html())
    })      
   })//$(&#39;#LoadPostContent&#39;).load

  }
 })  

  
  $(&quot;#link_code_ajaxLoad2&quot;).click(function(){
    var displayVal = $(&quot;#code_ajaxLoad2&quot;).css(&quot;display&quot;);
    if(displayVal == &quot;none&quot;){
     $(&quot;#link_code_ajaxLoad2&quot;).text(&quot;Click the link to hide code fragment&quot;);
     $(&quot;#code_ajaxLoad2&quot;).show();
    } else{
    $(&quot;#link_code_ajaxLoad2&quot;).text(&quot;Click the link to show code fragment&quot;);
    $(&quot;#code_ajaxLoad2&quot;).hide(); 
    }
  });
 });
  
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/2708659665547313566/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/2708659665547313566' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/2708659665547313566'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/2708659665547313566'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2010/06/jquery-by-examples-load-data-through.html' title='jQuery By Examples: Load data through Ajax - 2'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-8369666733456186494</id><published>2010-06-22T15:27:00.009+05:30</published><updated>2010-06-22T17:04:05.468+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="jQuery: By Examples"/><title type='text'>jQuery: By Examples - Link Preview</title><content type='html'>About the example:&lt;br /&gt;
When a user hovers over a link, sneak preview of the link pops up. And when user hovers over a thumbnail, original size image pops up.&lt;br /&gt;
&lt;br /&gt;
Link preview has been implemented through Ajax.load() function, where data for the link is loaded from one of the older posts. To know more about Ajax.load() function checkout &lt;br /&gt;
&lt;a href=&quot;http://myerrorslog.blogspot.com/2010/06/blog-post.html&quot;&gt;jQuery: By examples - Load data through Ajax&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Demo:&lt;br /&gt;
&lt;/h4&gt;&lt;div id=&quot;preview_container&quot;&gt; &lt;h4&gt;  &lt;a id=&quot;preview_link&quot; href=&quot;#&quot; onclick=&quot;return false;&quot;&gt;Preview Post - Introduction&lt;/a&gt;&amp;nbsp;&lt;br /&gt;
  &lt;a id=&quot;preview_image&quot; href=&quot;#&quot; onclick=&quot;return false;&quot;&gt;&lt;img class=&#39;preview_slice&#39; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi31rTCmKOFK8ZWN3TJXlcTZbS5QxUoxUowShvmxxW6Vn8qFFragyKT64oCshBTsk0HoWHGlbzfj9YHroREaEDy-uL3NuHqsEHf_wIHIzheqiVBIPjWE_mPP1n1viDMbQXLOZjMKSo3SxQ/s200/P1080602.JPG&quot; &gt;&lt;/a&gt;&lt;br /&gt;
 &lt;/h4&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h4&gt;&lt;a href=&quot;#&quot; id=&quot;link_code_preview&quot; onclick=&quot;return false;&quot;&gt;Click the link to show code fragment&lt;/a&gt;&lt;/h4&gt;&lt;div id=&quot;code_preview&quot; style=&quot;display: none;&quot;&gt;&lt;code&gt;&lt;br /&gt;
&amp;lt;!DOCTYPE HTML &amp;gt;&lt;br /&gt;
&amp;lt;HTML&amp;gt;&lt;br /&gt;
 &amp;lt;HEAD&amp;gt;&lt;br /&gt;
  &amp;lt;TITLE&amp;gt; Preview Link &amp;lt;/TITLE&amp;gt;&lt;br /&gt;
 &amp;lt;/HEAD&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;BODY&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&quot;preview_container&quot;&amp;gt;&lt;br /&gt;
 &amp;lt;a id=&quot;preview_link&quot; href=&quot;#&quot; onclick=&quot;return false;&quot;&amp;gt;Preview Post - Introduction&amp;lt;/a&amp;gt;&amp;nbsp;&lt;br /&gt;
 &amp;lt;a id=&quot;preview_image&quot; href=&quot;#&quot; onclick=&quot;return false;&quot;&amp;gt;&amp;lt;img class=&#39;preview_slice&#39; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi31rTCmKOFK8ZWN3TJXlcTZbS5QxUoxUowShvmxxW6Vn8qFFragyKT64oCshBTsk0HoWHGlbzfj9YHroREaEDy-uL3NuHqsEHf_wIHIzheqiVBIPjWE_mPP1n1viDMbQXLOZjMKSo3SxQ/s200/P1080602.JPG&quot; &amp;gt;&amp;lt;/a&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
 &amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
 &amp;lt;style type=&quot;text/css&quot;&amp;gt;&lt;br /&gt;
 #preview_sub_container{&lt;br /&gt;
  position: absolute;&lt;br /&gt;
  padding: .5em;&lt;br /&gt;
  background: #e3e3e3;&lt;br /&gt;
  border: 1px solid #bfbfbf;&lt;br /&gt;
  height: 100px;&lt;br /&gt;
  width: 500px;&lt;br /&gt;
 }&lt;br /&gt;
    #preview_container a img{&lt;br /&gt;
  border: none;&lt;br /&gt;
 }&lt;br /&gt;
 #preview_hover_image{&lt;br /&gt;
  position: absolute;&lt;br /&gt;
  padding: .5em;&lt;br /&gt;
  background: #e3e3e3;&lt;br /&gt;
  border: 1px solid #bfbfbf;&lt;br /&gt;
 }&lt;br /&gt;
 .preview_slice{&lt;br /&gt;
  height: 50px;&lt;br /&gt;
  width: 50px;&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;/style&amp;gt;&lt;br /&gt;
 &amp;lt;script type=&quot;text/javascript&quot;&amp;gt; &lt;br /&gt;
 $(function(){&lt;br /&gt;
  var page_offset = 20;&lt;br /&gt;
&lt;br /&gt;
  $(&quot;#preview_container a#preview_link&quot;).hover(function(event){&lt;br /&gt;
   $(&#39;&amp;lt;div id=&quot;preview_sub_container&quot; /&amp;gt;&#39;).load(&#39;http://myerrorslog.blogspot.com/2006/12/introduction.html div[class=&quot;post-body entry-content&quot;]&#39;, &lt;br /&gt;
   function(){&lt;br /&gt;
    $(this)&lt;br /&gt;
    .css(&#39;top&#39;, event.pageY + page_offset)&lt;br /&gt;
    .css(&#39;left&#39;, event.pageX + page_offset)&lt;br /&gt;
    .appendTo(&quot;#preview_container&quot;)&lt;br /&gt;
   })&lt;br /&gt;
  },&lt;br /&gt;
  function(){&lt;br /&gt;
  $(&quot;#preview_sub_container&quot;).remove()&lt;br /&gt;
  });&lt;br /&gt;
&lt;br /&gt;
  $(&quot;#preview_container a#preview_image&quot;).hover(function(event){&lt;br /&gt;
   var href = $(this).children(&#39;img&#39;).attr(&#39;src&#39;);&lt;br /&gt;
   &lt;br /&gt;
   $(&#39;&amp;lt;img id=&quot;preview_hover_image&quot; src=&quot;&#39;+ href +&#39;&quot; /&amp;gt;&#39;)    &lt;br /&gt;
    .css(&#39;top&#39;, event.pageY + page_offset)&lt;br /&gt;
    .css(&#39;left&#39;, event.pageX + page_offset)&lt;br /&gt;
    .appendTo(&quot;#preview_container&quot;) &lt;br /&gt;
  },&lt;br /&gt;
  function(){&lt;br /&gt;
  $(&quot;#preview_hover_image&quot;).remove()&lt;br /&gt;
  });&lt;br /&gt;
&lt;br /&gt;
  $(&quot;#preview_container a&quot;).mousemove(function(event){&lt;br /&gt;
   var object = &quot;#preview_hover_image&quot;;&lt;br /&gt;
   if($(this).attr(&#39;id&#39;) == &quot;preview_link&quot;){&lt;br /&gt;
    object = &quot;#preview_sub_container&quot; &lt;br /&gt;
   } &lt;br /&gt;
   $(object)&lt;br /&gt;
   .css(&#39;top&#39;, event.pageY + page_offset)&lt;br /&gt;
   .css(&#39;left&#39;, event.pageX + page_offset)&lt;br /&gt;
  });&lt;br /&gt;
&lt;br /&gt;
 });&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/BODY&amp;gt;&lt;br /&gt;
&amp;lt;/HTML&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;/div&gt;&lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt; 
 #preview_sub_container{
  position: absolute;
  padding: .5em;
  background: #e3e3e3;
  border: 1px solid #bfbfbf;
  height: 100px;
  width: 500px;
 }
    #preview_container a img{
  border: none;
 }
 #preview_hover_image{
  position: absolute;
  padding: .5em;
  background: #e3e3e3;
  border: 1px solid #bfbfbf;
 }
 .preview_slice{
  height: 50px;
  width: 50px;
 }
&lt;/style&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
 $(function(){

  var page_offset = 20;

  $(&quot;#preview_container a#preview_link&quot;).hover(function(event){
   $(&#39;&lt;div id=&quot;preview_sub_container&quot; /&gt;&#39;).load(&#39;http://myerrorslog.blogspot.com/2006/12/introduction.html div[class=&quot;post-body entry-content&quot;]&#39;, 
   function(){
    $(this)
    .css(&#39;top&#39;, event.pageY + page_offset)
    .css(&#39;left&#39;, event.pageX + page_offset)
    .appendTo(&quot;#preview_container&quot;)
   })
  },
  function(){
  $(&quot;#preview_sub_container&quot;).remove()
  });

  $(&quot;#preview_container a#preview_image&quot;).hover(function(event){
   var href = $(this).children(&#39;img&#39;).attr(&#39;src&#39;);
   
   $(&#39;&lt;img id=&quot;preview_hover_image&quot; src=&quot;&#39;+ href +&#39;&quot; /&gt;&#39;)    
    .css(&#39;top&#39;, event.pageY + page_offset)
    .css(&#39;left&#39;, event.pageX + page_offset)
    .appendTo(&quot;#preview_container&quot;) 
  },
  function(){
  $(&quot;#preview_hover_image&quot;).remove()
  });

  $(&quot;#preview_container a&quot;).mousemove(function(event){
   var object = &quot;#preview_hover_image&quot;;
   if($(this).attr(&#39;id&#39;) == &quot;preview_link&quot;){
    object = &quot;#preview_sub_container&quot; 
   } 
   $(object)
   .css(&#39;top&#39;, event.pageY + page_offset)
   .css(&#39;left&#39;, event.pageX + page_offset)
  });
  
  $(&quot;#link_code_preview&quot;).click(function(){
    var displayVal = $(&quot;#code_preview&quot;).css(&quot;display&quot;);
    if(displayVal == &quot;none&quot;){
     $(&quot;#link_code_preview&quot;).text(&quot;Click the link to hide code fragment&quot;);
     $(&quot;#code_preview&quot;).show();
    } else{
    $(&quot;#link_code_preview&quot;).text(&quot;Click the link to show code fragment&quot;);
    $(&quot;#code_preview&quot;).hide(); 
    }
  });
 });
  
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/8369666733456186494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/8369666733456186494' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/8369666733456186494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/8369666733456186494'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2010/06/jquery-by-examples-link-preview.html' title='jQuery: By Examples - Link Preview'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi31rTCmKOFK8ZWN3TJXlcTZbS5QxUoxUowShvmxxW6Vn8qFFragyKT64oCshBTsk0HoWHGlbzfj9YHroREaEDy-uL3NuHqsEHf_wIHIzheqiVBIPjWE_mPP1n1viDMbQXLOZjMKSo3SxQ/s72-c/P1080602.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-7704850760462842548</id><published>2010-06-21T12:33:00.013+05:30</published><updated>2010-07-06T09:17:32.218+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="jQuery: By Examples"/><title type='text'>jQuery: By examples - Load data through Ajax -1</title><content type='html'>&lt;div style=&quot;text-align: left;&quot;&gt;&amp;nbsp;This is another example in the series of jQuery: By Examples. In this example I will load data from one of the posts. Instead of loading complete post (including title) I will load data from a specific portion of the page. Following functions/methods are used in this example:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;.load( url, [ data ], [ complete(responseText, textStatus, XMLHttpRequest) ] )&lt;/li&gt;
&lt;li&gt;.hide()&lt;/li&gt;
&lt;li&gt;.appendTo()&lt;/li&gt;
&lt;li&gt;slideDown()&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;.load() method is the simplest way to get data from the server. Due to browser security restrictions, most &quot;Ajax&quot; requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol. Using the special syntax for url, you can get data from specif portion of the remote document. If the url has one or more spaces, the portion of the string following the first space is assumed to be a jQuery selector that determines the content to be loaded. For example:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;.load(&#39;http://myerrorslog.blogspot.com/2006/12/introduction.html div[class=&quot;post-body entry-content&quot;]&#39;)&lt;/li&gt;
&lt;/ul&gt;In this case I am fetching data from the DIV element whose CLASS attribute is equals to &lt;i&gt;post-body entry-content,&amp;nbsp; &lt;/i&gt;in the remote document - &lt;i&gt;http://myerrorslog.blogspot.com/2006/12/introduction.html&lt;/i&gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;h4&gt;Demo:&lt;/h4&gt;&lt;div id=&quot;ajax_container&quot;&gt;&lt;h4&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=7900835119661228409&amp;amp;postID=7704850760462842548#&quot; id=&quot;ajax_loadPost&quot; onclick=&quot;return false;&quot;&gt;Click the link to Load a Post &lt;/a&gt;&lt;/h4&gt;&lt;/div&gt;&lt;h4&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=7900835119661228409&amp;amp;postID=7704850760462842548#&quot; id=&quot;link_code_ajax&quot; onclick=&quot;return false;&quot;&gt;Click the link to show code fragment&lt;/a&gt;&lt;/h4&gt;&lt;div id=&quot;code_ajax&quot; style=&quot;display: none;&quot;&gt;&lt;code&gt;&lt;br /&gt;
&amp;lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;&amp;gt;&lt;br /&gt;
&amp;lt;HTML&amp;gt;&lt;br /&gt;
&amp;lt;HEAD&amp;gt;&lt;br /&gt;
&amp;lt;TITLE&amp;gt; Day 10 - Ajax load() &amp;lt;/TITLE&amp;gt;&lt;br /&gt;
&amp;lt;/HEAD&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;BODY&amp;gt;&lt;br /&gt;
&amp;lt;div id=&quot;ajax_container&quot;&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt;&amp;lt;a id=&quot;ajax0_loadPost&quot; href=&quot;#&quot; onclick=&quot;return false;&quot;&amp;gt;Click the link to Load a Post &amp;lt;/a&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&lt;br /&gt;
$(function(){&lt;br /&gt;
$(&quot;a#ajax_loadPost&quot;).click(function(){&lt;br /&gt;
$(&#39;&amp;lt;div id=&quot;ajax0_postData&quot; /&amp;gt;&#39;).load(&#39;http://myerrorslog.blogspot.com/2006/12/introduction.html div[class=&quot;post-body entry-content&quot;]&#39;, function(){&lt;br /&gt;
$(this).hide().appendTo(&quot;#ajax_container&quot;).slideDown(1000)&lt;br /&gt;
})&lt;br /&gt;
})&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/BODY&amp;gt;&lt;br /&gt;
&amp;lt;/HTML&amp;gt;       &lt;br /&gt;
&lt;/code&gt;&lt;/div&gt;&lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
 .ajax_description{
  display: none;
 }
 .ajax_link{
 text-decoration: underline;
 }
&lt;/style&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
 $(function(){
  $(&quot;a#ajax_loadPost&quot;).click(function(){
    $(&#39;&lt;div id=&quot;ajax_postData&quot; /&gt;&#39;).load(&#39;http://myerrorslog.blogspot.com/2006/12/introduction.html div[class=&quot;post-body entry-content&quot;]&#39;, function(){
     $(this).hide().appendTo(&quot;#ajax_container&quot;).slideDown(1000)
    })
  });
  
  $(&quot;#link_code_ajax&quot;).click(function(){
    var displayVal = $(&quot;#code_ajax&quot;).css(&quot;display&quot;);
    if(displayVal == &quot;none&quot;){
     $(&quot;#link_code_ajax&quot;).text(&quot;Click the link to hide code fragment&quot;);
     $(&quot;#code_ajax&quot;).show();
    } else{
    $(&quot;#link_code_ajax&quot;).text(&quot;Click the link to show code fragment&quot;);
    $(&quot;#code_ajax&quot;).hide(); 
    }
  });
 });
  
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/7704850760462842548/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/7704850760462842548' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/7704850760462842548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/7704850760462842548'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2010/06/blog-post.html' title='jQuery: By examples - Load data through Ajax -1'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-63429437765690730</id><published>2010-06-09T16:00:00.011+05:30</published><updated>2010-06-09T17:47:27.380+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="jQuery: By Examples"/><title type='text'>Recursive call through arguments.callee</title><content type='html'>Is it possible for an anonymous function to refer itself in javascript?&lt;br /&gt;
When I read the question for the first time even I was totally blank. The very next thought came to my mind was &quot;Is it really possible?&quot;.&lt;br /&gt;
Well the answer is YES. It is possible for an anonymous function to refer itself through the use of arguments.callee. &lt;br /&gt;
arguments is a local variable for a function object. callee is one of the properties of arguments. arguments.callee allows anonymous function to refer to itself, which is necessary for recursion. Here is an example:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example: &lt;/b&gt;In this example, I will use arguments.callee within an anonymous function which is used as a callback for show() and hide() methods.&lt;br /&gt;
&lt;h4&gt;Demo:&lt;/h4&gt;&lt;div&gt;&lt;h4&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=7900835119661228409&amp;amp;postID=63429437765690730#&quot; id=&quot;api_list_link&quot; onclick=&quot;return false;&quot;&gt;Show the API list&lt;/a&gt;&lt;/h4&gt;&lt;ul class=&quot;description&quot; id=&quot;apis_list&quot;&gt;&lt;li class=&quot;description&quot;&gt;&lt;a class=&quot;link&quot; href=&quot;http://www.blogger.com/post-edit.g?blogID=7900835119661228409&amp;amp;postID=63429437765690730#&quot; onclick=&quot; return false;&quot;&gt;ID Selector (&quot;#id&quot;)&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;description&quot;&gt;Select an element based on the id value. For id selectors, jQuery uses the JavaScript function document.getElementById(), which is extremely efficient. When another selector is attached to the id selector, such as h2#pageTitle, jQuery performs an additional check before identifying the element as a match. &lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;description&quot;&gt;&lt;a class=&quot;link&quot; href=&quot;http://www.blogger.com/post-edit.g?blogID=7900835119661228409&amp;amp;postID=63429437765690730#&quot; onclick=&quot; return false;&quot;&gt;:first Selector&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;description&quot;&gt;Selects the first matched element. The :first pseudo-class is equivalent to :eq(0). It could also be written as :lt(1). While this matches only a single element, :first-child can match more than one: One for each parent. &lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;description&quot;&gt;&lt;a class=&quot;link&quot; href=&quot;http://www.blogger.com/post-edit.g?blogID=7900835119661228409&amp;amp;postID=63429437765690730#&quot; onclick=&quot; return false;&quot;&gt;:last Selector&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;description&quot;&gt;Selects the last matched element. Note that :last selects a single element by filtering the current jQuery collection and matching the last element within it.&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;description&quot;&gt;&lt;a class=&quot;link&quot; href=&quot;http://www.blogger.com/post-edit.g?blogID=7900835119661228409&amp;amp;postID=63429437765690730#&quot; onclick=&quot; return false;&quot;&gt;Mouse Event - click()&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;description&quot;&gt;Bind an event handler to the &quot;click&quot; JavaScript event, or trigger that event on an element. The click event is sent to an element when the mouse pointer is over the element, and the mouse button is pressed and released. Any HTML element can receive this event.&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;description&quot;&gt;&lt;a class=&quot;link&quot; href=&quot;http://www.blogger.com/post-edit.g?blogID=7900835119661228409&amp;amp;postID=63429437765690730#&quot; onclick=&quot; return false;&quot;&gt;show(duration, [ callback ] )&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;description&quot;&gt;Display the matched elements. When a duration is provided, .show() becomes an animation method. The .show() method animates the width, height, and opacity of the matched elements simultaneously. If supplied, the callback is fired once the animation is complete. &lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;description&quot;&gt;&lt;a class=&quot;link&quot; href=&quot;http://www.blogger.com/post-edit.g?blogID=7900835119661228409&amp;amp;postID=63429437765690730#&quot; onclick=&quot; return false;&quot;&gt;hide(duration, [ callback ] )&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;description&quot;&gt;Hide the matched elements. When a duration is provided, .hide() becomes an animation method. The .hide() method animates the width, height, and opacity of the matched elements simultaneously. When these properties reach 0, the display style property is set to none to ensure that the element no longer affects the layout of the page. If supplied, the callback is fired once the animation is complete.&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h4&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=7900835119661228409&amp;amp;postID=63429437765690730#&quot; id=&quot;link_code_callee&quot; onclick=&quot;return false;&quot;&gt;Click the link to show code fragment&lt;/a&gt;&lt;/h4&gt;&lt;div id=&quot;code_callee&quot; style=&quot;display: none;&quot;&gt;&lt;code&gt;&lt;br /&gt;
&amp;lt;!DOCTYPE HTML&amp;gt;&lt;br /&gt;
&amp;lt;HTML&amp;gt;&lt;br /&gt;
&amp;lt;HEAD&amp;gt;&lt;br /&gt;
&amp;lt;TITLE&amp;gt; jQuery Examples &amp;lt;/TITLE&amp;gt;  &lt;br /&gt;
&amp;lt;/HEAD&amp;gt;&lt;br /&gt;
&amp;lt;BODY&amp;gt;    &lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&amp;lt;h4&amp;gt; &amp;lt;a id=&quot;api_list_link&quot; onclick=&quot;return false;&quot; href=&quot;#&quot;&amp;gt;Show the API list&amp;lt;/a&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&amp;lt;ul id=&#39;api_list&#39; class=&quot;description&quot;&amp;gt;&lt;br /&gt;
&amp;lt;li class=&quot;description&quot;&amp;gt;&amp;lt;a class=&quot;link&quot; onclick=&quot; return false;&quot; href=&quot;#&quot;&amp;gt;ID Selector (&quot;#id&quot;)&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;div class=&quot;description&quot;&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li class=&quot;description&quot;&amp;gt;&amp;lt;a class=&quot;link&quot; onclick=&quot; return false;&quot; href=&quot;#&quot;&amp;gt;:first Selector&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;div class=&quot;description&quot;&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li class=&quot;description&quot;&amp;gt;&amp;lt;a class=&quot;link&quot; onclick=&quot; return false;&quot; href=&quot;#&quot;&amp;gt;:last Selector&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;div class=&quot;description&quot;&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li class=&quot;description&quot;&amp;gt;&amp;lt;a class=&quot;link&quot; onclick=&quot; return false;&quot; href=&quot;#&quot;&amp;gt;Mouse Event - click()&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;div class=&quot;description&quot;&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li class=&quot;description&quot;&amp;gt;&amp;lt;a class=&quot;link&quot; onclick=&quot; return false;&quot; href=&quot;#&quot;&amp;gt;DOM Removal - remove()&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;div class=&quot;description&quot;&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li class=&quot;description&quot;&amp;gt;&amp;lt;a class=&quot;link&quot; onclick=&quot; return false;&quot; href=&quot;#&quot;&amp;gt;DOM Insertion - appendTo()&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;div class=&quot;description&quot;&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;style type=&quot;text/css&quot;&amp;gt;&lt;br /&gt;
.box{&lt;br /&gt;
height: 65px;&lt;br /&gt;
width: 300px; &lt;br /&gt;
padding-top: 20px;&lt;br /&gt;
font-size:36px;&lt;br /&gt;
color:green;&lt;br /&gt;
text-align: center;&lt;br /&gt;
position: absolute;&lt;br /&gt;
}&lt;br /&gt;
.description{&lt;br /&gt;
display: none;&lt;br /&gt;
}&lt;br /&gt;
.link{&lt;br /&gt;
text-decoration: underline;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&lt;br /&gt;
$(function(){&lt;br /&gt;
$(&quot;#api_list_link&quot;).click(function(){&lt;br /&gt;
var displayProp = $(&quot;ul#api_list&quot;).css(&quot;display&quot;);&lt;br /&gt;
if(displayProp==&quot;none&quot;){&lt;br /&gt;
$(&quot;#api_list_link&quot;).text(&quot;Hide the API list&quot;);&lt;br /&gt;
$(&quot;ul#api_list&quot;).show();&lt;br /&gt;
$(&quot;ul#api_list li:first&quot;).stop().show(&quot;fast&quot;, function(){     &lt;br /&gt;
$(this).next(&quot;ul#api_list li&quot;).show(&quot;fast&quot;, &lt;b&gt;arguments.callee&lt;/b&gt;);&lt;br /&gt;
}); &lt;br /&gt;
} else{&lt;br /&gt;
$(&quot;#api_list_link&quot;).text(&quot;Show the API list&quot;);&lt;br /&gt;
$(&quot;ul#api_list li:last&quot;).stop().hide(&quot;fast&quot;, function(){&lt;br /&gt;
displayProp = &quot;none&quot;;&lt;br /&gt;
$(this).prev(&quot;ul#api_list li&quot;).hide(&quot;fast&quot;, &lt;b&gt;arguments.callee&lt;/b&gt;);&lt;br /&gt;
}); &lt;br /&gt;
if(displayProp==&quot;none&quot;){&lt;br /&gt;
$(&quot;ul#api_list&quot;).hide();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
});&lt;br /&gt;
$(&quot;ul#api_list li a&quot;).click(function(){&lt;br /&gt;
$(&quot;ul#api_list div&quot;).hide();&lt;br /&gt;
$(this).parent().children(&quot;div&quot;).fadeIn(&quot;slow&quot;);&lt;br /&gt;
})&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/BODY&amp;gt;&lt;br /&gt;
&amp;lt;/HTML&amp;gt;       &lt;br /&gt;
&lt;/code&gt;&lt;/div&gt;&lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
 .box{
  height: 65px;
  width: 300px; 
  padding-top: 20px;
  font-size:36px;
  color:green;
  text-align: center;
  position: absolute;
 }
 .description{
  display: none;
 }
 .link{
 text-decoration: underline;
 }

  
&lt;/style&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
 $(function(){
  $(&quot;#api_list_link&quot;).click(function(){
   var displayProp = $(&quot;ul#apis_list&quot;).css(&quot;display&quot;);
   
   if(displayProp==&quot;none&quot;){
   $(&quot;#api_list_link&quot;).text(&quot;Hide the API list&quot;);
    $(&quot;ul#apis_list&quot;).show();

    $(&quot;ul#apis_list li:first&quot;).stop().show(&quot;fast&quot;, function(){     
     $(this).next(&quot;ul#apis_list li&quot;).show(&quot;fast&quot;, arguments.callee);
    }); 
   } else{
   $(&quot;#api_list_link&quot;).text(&quot;Show the API list&quot;);
    $(&quot;ul#apis_list li:last&quot;).stop().hide(&quot;fast&quot;, function(){
     displayProp = &quot;none&quot;;
     $(this).prev(&quot;ul#apis_list li&quot;).hide(&quot;fast&quot;, arguments.callee);
    }); 
    if(displayProp==&quot;none&quot;){
     $(&quot;ul#apis_list&quot;).hide();
    }
   }

  });
  
  $(&quot;ul#apis_list li a&quot;).click(function(){
   $(&quot;ul#apis_list div&quot;).hide();
   $(this).parent().children(&quot;div&quot;).fadeIn(&quot;slow&quot;);
  })
  
  $(&quot;#link_code_callee&quot;).click(function(){
    var displayVal = $(&quot;#code_callee&quot;).css(&quot;display&quot;);
    if(displayVal == &quot;none&quot;){
     $(&quot;#link_code_callee&quot;).text(&quot;Click the link to hide code fragment&quot;);
     $(&quot;#code_callee&quot;).show();
    } else{
    $(&quot;#link_code_callee&quot;).text(&quot;Click the link to show code fragment&quot;);
    $(&quot;#code_callee&quot;).hide(); 
    }
  });
 });
  
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/63429437765690730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/63429437765690730' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/63429437765690730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/63429437765690730'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2010/06/recursive-call-through-argumentscallee.html' title='Recursive call through arguments.callee'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-7141847595878291335</id><published>2010-06-08T16:51:00.022+05:30</published><updated>2010-06-09T17:58:44.757+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="jQuery: By Examples"/><title type='text'>jQuery: By examples</title><content type='html'>I have been playing around with jQuery from last few days. And I AM LOVING IT. Well still I am in the learning phase, but I thought lets share what I have learnt so far. And the best way to share the knowledge is though EXAMPLES. So here is the first set of examples:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example&lt;/b&gt;: In this example I will flip a box. &lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Demo: Click on the box to flip it&lt;/h4&gt;&lt;div id=&quot;container&quot;&gt;&lt;div class=&quot;box&quot; style=&quot;background: yellow&quot;&gt;&lt;span&gt;eM pliF&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;box&quot; style=&quot;background: red&quot;&gt;&lt;span&gt;Filp Me&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;h4&gt;APIs used in the example (this section is also implemented through jQuery)&lt;/h4&gt;&lt;ul id=&#39;api_list&#39;&gt;&lt;li&gt;&lt;a class=&quot;link&quot; onclick=&quot; return false;&quot; href=&quot;#&quot;&gt;ID Selector (&quot;#id&quot;)&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;description&quot;&gt;Select an element based on the id value. For id selectors, jQuery uses the JavaScript function document.getElementById(), which is extremely efficient. When another selector is attached to the id selector, such as h2#pageTitle, jQuery performs an additional check before identifying the element as a match. &lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;link&quot; onclick=&quot; return false;&quot; href=&quot;#&quot;&gt;:first Selector&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;description&quot;&gt;Selects the first matched element. The :first pseudo-class is equivalent to :eq(0). It could also be written as :lt(1). While this matches only a single element, :first-child can match more than one: One for each parent. &lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;link&quot; onclick=&quot; return false;&quot; href=&quot;#&quot;&gt;:last Selector&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;description&quot;&gt;Selects the last matched element. Note that :last selects a single element by filtering the current jQuery collection and matching the last element within it.&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;link&quot; onclick=&quot; return false;&quot; href=&quot;#&quot;&gt;Mouse Event - click()&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;description&quot;&gt;Bind an event handler to the &quot;click&quot; JavaScript event, or trigger that event on an element. The click event is sent to an element when the mouse pointer is over the element, and the mouse button is pressed and released. Any HTML element can receive this event.&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;link&quot; onclick=&quot; return false;&quot; href=&quot;#&quot;&gt;DOM Removal - remove()&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;description&quot;&gt;Remove the set of matched elements from the DOM. We use .remove() when we want to remove the element itself, as well as everything inside it. In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;link&quot; onclick=&quot; return false;&quot; href=&quot;#&quot;&gt;DOM Insertion - appendTo()&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;description&quot;&gt;Insert every element in the set of matched elements to the end of the target. With .appendTo(), the content precedes the method, either as a selector expression or as markup created on the fly, and it is inserted into the target container.&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h4&gt;&lt;a id=&quot;link_code_example01&quot; onclick=&quot;return false;&quot; href=&quot;#&quot;&gt;Click the link to show code fragment&lt;/a&gt;&lt;/h4&gt;&lt;div id=&quot;code_example01&quot; style=&quot;display:none&quot;&gt;&lt;code&gt;&lt;br /&gt;
&amp;lt;!DOCTYPE HTML &amp;gt;&lt;br /&gt;
&amp;lt;HTML&amp;gt;&lt;br /&gt;
&amp;lt;HEAD&amp;gt;&lt;br /&gt;
&amp;lt;TITLE&amp;gt; jQuery - By Examples &amp;lt;/TITLE&amp;gt;&lt;br /&gt;
&lt;b&gt;// import jquery-latest.min.js from code.jquery.com&lt;/b&gt; &lt;br /&gt;
&amp;lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;style type=&quot;text/css&quot;&amp;gt;&lt;br /&gt;
.box{&lt;br /&gt;
height: 65px;&lt;br /&gt;
width: 300px;&lt;br /&gt;
padding-top:20px;  &lt;br /&gt;
font-size:36px;&lt;br /&gt;
color:green;&lt;br /&gt;
text-align: center;&lt;br /&gt;
position: absolute;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&lt;br /&gt;
$(function(){&lt;br /&gt;
/*&lt;br /&gt;
Example of Flip&lt;br /&gt;
*/&lt;br /&gt;
$(&quot;#container&quot;).click(function(){&lt;br /&gt;
&lt;b&gt;&lt;i&gt;// get the top div element from the container div&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
var first = $(&quot;#container div:first&quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;//get the last div element from the container div&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
var last = $(&quot;#container div:last&quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;//remove all the div elements from the container div&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
$(&quot;#container div&quot;).remove();&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;// now add the div elements into the reverse order to the container div&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
$(last).appendTo(&quot;#container&quot;);&lt;br /&gt;
$(first).appendTo(&quot;#container&quot;);&lt;br /&gt;
});  &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;div id=&quot;container&quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&quot;box&quot; style=&quot;background: yellow&quot;&amp;gt;&amp;lt;span&amp;gt;eM pliF&amp;lt;/span&amp;gt;&amp;lt;/div&amp;gt;   &lt;br /&gt;
&amp;lt;div class=&quot;box&quot; style=&quot;background: red&quot;&amp;gt;&amp;lt;span&amp;gt;Filp Me&amp;lt;/span&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/BODY&amp;gt;&lt;br /&gt;
&amp;lt;/HTML&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
 .box{
  height: 65px;
  width: 300px;
  padding-top: 20px; 
  font-size:36px;
  color:green;
  text-align: center;
  position: absolute;
 }
 .description{
  display: none;
 }
 .link{
 text-decoration: underline;
 }

  &lt;/style&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
 $(function(){
/*
 Example of Flip/Swap - interchange boxes
*/
  $(&quot;#container&quot;).click(function(){
   var first = $(&quot;#container div:first&quot;);
   var last = $(&quot;#container div:last&quot;);
   $(&quot;#container div&quot;).remove();
   $(last).appendTo(&quot;#container&quot;);
   $(first).appendTo(&quot;#container&quot;);
  }); 
  
  $(&quot;ul#api_list li a&quot;).click(function(){
   $(&quot;ul#api_list div&quot;).hide();
   $(this).parent().children(&quot;div&quot;).fadeIn(&quot;slow&quot;);
  });

  $(&quot;#link_code_example01&quot;).click(function(){
    var displayVal = $(&quot;#code_example01&quot;).css(&quot;display&quot;);
    if(displayVal == &quot;none&quot;){
     $(&quot;#link_code_example01&quot;).text(&quot;Click the link to hide code fragment&quot;);
     $(&quot;#code_example01&quot;).show();
    } else{
    $(&quot;#link_code_example01&quot;).text(&quot;Click the link to show code fragment&quot;);
    $(&quot;#code_example01&quot;).hide(); 
    }
  });

 });
  &lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/7141847595878291335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/7141847595878291335' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/7141847595878291335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/7141847595878291335'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2010/06/jquery-by-examples.html' title='jQuery: By examples'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-9172937661171445672</id><published>2009-03-27T11:52:00.004+05:30</published><updated>2010-06-18T14:30:00.378+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Back To School"/><title type='text'>How to Unzip a File</title><content type='html'>Follow the steps given below to Unzip a file on Server:&lt;br /&gt;&lt;br /&gt;1. Create a File object from the uplodaded data -  If you have used Struts framwork to upload a Zip file, then first get the FormFile object (org.apache.struts.upload.FormFile).&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    FormFile formFile = form.getFileProperties();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;From FormFile object get the InputStream.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;    InputStream inputStream = formFile.getInputStream();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In case we are getting the data within a hidden field in base-64 / zipped format, FormFile is null. In that case get the byte[] data using: sun.misc.BASE64Decoder().decodeBuffer() method if  Enctype  is  *B64*&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;   if(form.getEnctype().equals(&quot;*B64*&quot;))&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;      byte[] rawData = sun.misc.BASE64Decoder().decodeBuffer(form.Data());&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Create ByteArryaIntputStream from byte[] data.&lt;br /&gt;&lt;br /&gt;   &lt;span style=&quot;;font-family:courier new;font-size:85%;&quot;  &gt;InputStream inputStream = new ByteArrayInputStream(rawData);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now create a File object in which you want to read the InputStream.&lt;br /&gt;&lt;br /&gt;   &lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;File fileObj = new File(&quot;test.zip&quot;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Create a FileOutputStream from the File object.&lt;br /&gt; &lt;br /&gt;   &lt;span style=&quot;;font-family:courier new;font-size:85%;&quot;  &gt;OutputStream outputStream = new FileOutputStream(fileObj);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now read the IntputStream and write it to OutputStream.&lt;br /&gt;&lt;br /&gt;2. Once the File object is created, next is  to create a ZipFile (java.util.zip.ZipFile) object from it.&lt;br /&gt;&lt;br /&gt;   &lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;ZipFile zipFile = new ZipFile(fileObject);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;3. Iterate through the ZipFile to read the zip and extract its contents.&lt;br /&gt;&lt;br /&gt;Below is the complete soure code.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;;font-family:courier new;font-size:85%;&quot;  &gt;import org.apache.struts.upload.*;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;import java.util.*;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;import java.util.zip.ZipFile;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;import java.util.zip.ZipEntry;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;import java.io.*;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;public class unzipUtility&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    public static final String B64String = &quot;*B64*&quot;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    public void unzipFile(ActionForm form)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    {&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        InputStream inputStream = null;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        OutputStream outputStream = null;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        File fileObj = new File(&quot;test.zip&quot;);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        FormFile formFile = form.getFormFile();// not the standard method&lt;br /&gt;&lt;br /&gt;        if(formFile!=null)&lt;br /&gt;        {&lt;br /&gt;            inputStream = formFile.getInputStream();&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        byte[] rawData = null;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;            if(form.getEnctype().equals(B64String))&lt;br /&gt;            {&lt;br /&gt;                rawData = new sun.misc.BASE64Decoder().decodeBuffer(form.getData());&lt;br /&gt;            }      &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;   &lt;br /&gt;            inputStream = new ByteArrayInputStream(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;rawData&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;    outputStream = FileOutputStream(fileObj);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        copyStream(inputStream, outputStream);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;       }&lt;br /&gt;&lt;br /&gt;    private byte[] getRawData(String content)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;    }// getRawData()&lt;br /&gt;&lt;br /&gt;    private void copyStream(InputStream input, OutputStream output)&lt;br /&gt;    {&lt;br /&gt;        int size;&lt;br /&gt;        byte[] buffer = new byte[1024];&lt;br /&gt;&lt;br /&gt;        while((size=input.read(buffer))&gt;=0)&lt;br /&gt;        {&lt;br /&gt;            output.write(buffer, 0, size);&lt;br /&gt;        }//while&lt;br /&gt;   &lt;br /&gt;        input.close();&lt;br /&gt;        output.close();&lt;br /&gt;    }//copyStream()&lt;br /&gt;&lt;br /&gt;    public  void unzip(File fileObj)&lt;br /&gt;    {&lt;br /&gt;        Enumeration entries;&lt;br /&gt;        ZipFile zipFile;&lt;br /&gt;&lt;br /&gt;    try {&lt;br /&gt;      zipFile = new ZipFile(fileObj);&lt;br /&gt;&lt;br /&gt;      entries = zipFile.entries();&lt;br /&gt;&lt;br /&gt;      while(entries.hasMoreElements()) {&lt;br /&gt;        ZipEntry entry = (ZipEntry)entries.nextElement();&lt;br /&gt;&lt;br /&gt;        if(entry.isDirectory()) {&lt;br /&gt;          // Assume directories are stored parents first then children.&lt;br /&gt;          System.err.println(&quot;Extracting directory: &quot; + entry.getName());&lt;br /&gt;          // This is not robust, just for demonstration purposes.&lt;br /&gt;          (new File(entry.getName())).mkdir();&lt;br /&gt;          continue;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        System.err.println(&quot;Extracting file: &quot; + entry.getName());&lt;br /&gt;        copyInputStream(zipFile.getInputStream(entry),&lt;br /&gt;           new BufferedOutputStream(new FileOutputStream(entry.getName())));&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      zipFile.close();&lt;br /&gt;    } catch (IOException ioe) {&lt;br /&gt;      System.err.println(&quot;Unhandled exception:&quot;);&lt;br /&gt;      ioe.printStackTrace();&lt;br /&gt;      return;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/9172937661171445672/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/9172937661171445672' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/9172937661171445672'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/9172937661171445672'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2009/03/how-to-unzip-file.html' title='How to Unzip a File'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-1678551914838480135</id><published>2009-02-24T10:24:00.001+05:30</published><updated>2009-03-27T14:56:14.237+05:30</updated><title type='text'>Unable to run multiple instances of WEBLOGIC on the same machine</title><content type='html'>&lt;div&gt;I have been facing this issue from couple of days. Searched alot on the net also, but not able to get any satisfactory results. What ever i have got was in bits-n-pieces. From hit and trial I have come up with the following solution:&lt;/div&gt;&lt;br /&gt;&lt;div&gt; &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/1678551914838480135/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/1678551914838480135' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/1678551914838480135'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/1678551914838480135'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2009/02/unable-to-run-multiple-instances-of.html' title='Unable to run multiple instances of WEBLOGIC on the same machine'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-1838349654269457815</id><published>2007-05-25T11:38:00.000+05:30</published><updated>2010-06-18T14:30:00.378+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Back To School"/><title type='text'>What is Encapsulation?</title><content type='html'>&lt;span style=&quot;font-family:arial;&quot;&gt;Encapsulation refers to the bundling of data with the methods that operate on that data. Often that definition is misconstrued to mean that the data is somehow hidden. In Java, you can have encapsulated data that is not hidden at all. &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Encapsulation or equivalently information hiding refers to the practice of including within an object everything it needs, and furthermore doing this in such a way that no other object need ever be aware of this internal structure.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/1838349654269457815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/1838349654269457815' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/1838349654269457815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/1838349654269457815'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2007/05/what-is-encapsulation.html' title='What is Encapsulation?'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-8294495942531599842</id><published>2007-05-25T10:33:00.000+05:30</published><updated>2010-06-18T14:30:00.379+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Back To School"/><title type='text'>What is Abstraction?</title><content type='html'>&lt;span style=&quot;font-family:arial;&quot;&gt;Here are couple of definitions of Abstraction - &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Abstraction (from the Latin abs, meaning away from and trahere, meaning to draw) is the process of taking away or removing characteristics from something in order to reduce it to a set of essential characteristics. In object-oriented programming, abstraction is one of three central principles (along with encapsulation and inheritance). Through the process of abstraction, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency. In the same way that abstraction sometimes works in art, the object that remains is a representation of the original, with unwanted detail omitted. The resulting object itself can be referred to as an abstraction, meaning a named entity made up of selected attributes and behavior specific to a particular usage of the originating entity. Abstraction is related to both encapsulation and data hiding.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Abstraction is the process of hiding the details and exposing only the essential features of a particular concept or object. &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;A view of a problem that extracts the essential information relevant to a particular purpose and ignores the remainder of the information.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;The essence of abstraction is to extract essential properties while omitting inessential details.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/8294495942531599842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/8294495942531599842' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/8294495942531599842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/8294495942531599842'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2007/05/what-is-abstraction.html' title='What is Abstraction?'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-4348675410739464024</id><published>2007-05-08T18:11:00.002+05:30</published><updated>2010-06-18T14:29:01.093+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Back To School"/><title type='text'>What is the difference between &amp;lt;%@ include file=&quot;abc.jsp&quot; %&amp;gt; and &amp;lt;jsp:include page=&quot;abc.jsp&quot; %&amp;gt; ?</title><content type='html'>&lt;strong&gt;&lt;/strong&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;The &amp;lt;%@include file=&quot;abc.jsp&quot;%&amp;gt; directive acts like C &quot;#include&quot;, pulling in the text of the included file and compiling it as if it were part of the including file. The included file can be any type (including HTML or text).&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family:arial;&quot;&gt;The &amp;lt;jsp:include page=&quot;abc.jsp&quot;&amp;gt; tag compiles the file as a separate JSP file, and embeds a call to it in the compiled JSP.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family:arial;&quot;&gt;Some JSP engines support the non-standard tags &amp;lt;!--#include file=&quot;data.inc&quot;--&amp;gt; (NCSA-, or .shtml-style) and &amp;lt;%@ vinclude=&quot;data.inc&quot; %&amp;gt; (JRun-style), but these are not defined in the JSP spec and thus cannot be relied on. &lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/4348675410739464024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/4348675410739464024' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/4348675410739464024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/4348675410739464024'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2007/05/what-is-difference-between-include.html' title='What is the difference between &amp;lt;%@ include file=&quot;abc.jsp&quot; %&amp;gt; and &amp;lt;jsp:include page=&quot;abc.jsp&quot; %&amp;gt; ?'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-4301965344835970232</id><published>2007-05-08T13:17:00.001+05:30</published><updated>2009-03-27T14:56:13.539+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="What&#39;s New"/><title type='text'>D.S.L.</title><content type='html'>DSL!! When I heard this word for the very first time from Amit, I interpreted it as Digital Subscriber Line. He also told me that “DSL” is very hot these days and he is working on it. But what is a J2EE developer has to do with DSL. I was confused and lost completely.&lt;br /&gt;&lt;br /&gt;Oh I forgot to introduce Amit. His full name is Amit Swami. At present working with a renowned company called &lt;a href=&quot;http://www.thoughtworks.com/&quot;&gt;ThoughtWorks&lt;/a&gt;. He is my collage mate and the only source of information about new happenings in the world of IT. For any J2EE related questions you can buzz him, which I regularly do. And not to mention that he is one of the few good friends I have.&lt;br /&gt;&lt;br /&gt;Ok back to the story. I thought he is trying to make a switch, which is very possible with him. But again WHY? Then after two three days I asked him – “Is every thing OK?”. He said “Yes”. “Then why you are trying to make a switch to a whole new world?” I asked. Now he was punch-drunk and without wasting time immediately replied – “WHAT!! What are you talking about? Who told you that? Why would I need to change my job?”. These are very few whats and whys. “Then why you are working on DSL – digital subscriber Line?”. The moment I ended my sentence he was howling. He was literally laid down on the floor and laughing and screaming – “Oh GOD”. I was sitting idle with not even a single expression on my face and thinking – “Did I pass a joke?”. After few minute some how he was able to control himself and said - “DSL stands for Domain Specific Language”. So guys now you know that DSL “ALSO” stands for Domain Specific Language. “Haaaaaaaaaaaaahaaaaaaaaaaa”…..this is how I ended the memorable and mind blowing conversation. So here are the details of DSL and this time it is Domain Specific Language.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Domain-specific programming language&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style=&quot;;font-family:arial;font-size:78%;&quot;  &gt;From Wikipedia, the free encyclopedia&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;A domain-specific programming language (domain-specific language, DSL) is a &lt;/span&gt;&lt;a title=&quot;Programming language&quot; href=&quot;http://en.wikipedia.org/wiki/Programming_language&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;programming language&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:arial;&quot;&gt; designed to be useful for a specific set of tasks. This is in contrast to general-purpose programming language (general-purpose language, GPL), such as &lt;/span&gt;&lt;a title=&quot;C (programming language)&quot; href=&quot;http://en.wikipedia.org/wiki/C_%28programming_language%29&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;C&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:arial;&quot;&gt; or &lt;/span&gt;&lt;a title=&quot;Java (programming language)&quot; href=&quot;http://en.wikipedia.org/wiki/Java_%28programming_language%29&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Java&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;, or general-purpose modeling languages like &lt;/span&gt;&lt;a title=&quot;Unified Modeling Language&quot; href=&quot;http://en.wikipedia.org/wiki/Unified_Modeling_Language&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;UML&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;. Examples of DSLs include &lt;/span&gt;&lt;a title=&quot;Spreadsheet&quot; href=&quot;http://en.wikipedia.org/wiki/Spreadsheet&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;spreadsheet&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:arial;&quot;&gt; macros, &lt;/span&gt;&lt;a title=&quot;Yacc&quot; href=&quot;http://en.wikipedia.org/wiki/Yacc&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;YACC&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:arial;&quot;&gt; for parsing and compilers, &lt;/span&gt;&lt;a title=&quot;Generic Eclipse Modeling System&quot; href=&quot;http://en.wikipedia.org/wiki/Generic_Eclipse_Modeling_System&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Generic Eclipse Modeling System&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:arial;&quot;&gt; for creating diagramming languages, &lt;/span&gt;&lt;a title=&quot;Csound&quot; href=&quot;http://en.wikipedia.org/wiki/Csound&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Csound&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;, a language used to create audio files, and &lt;/span&gt;&lt;a title=&quot;GraphViz&quot; href=&quot;http://en.wikipedia.org/wiki/GraphViz&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;GraphViz&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;, a language used to define and create visual representations for directed graphs.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;DSLs have also been called by various names:&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Little languages &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Macros (in reference to the macro feature found in spreadsheets, word processors, and other applications, and not to the powerful &lt;/span&gt;&lt;a title=&quot;Macro&quot; href=&quot;http://en.wikipedia.org/wiki/Macro&quot;&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;programming language macros&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;, which are frequently employed to implement DSLs) &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Application languages &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Very high level languages &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;DSLs focus on doing one sort of task well. For instance, GraphViz is designed to create images of graphs in a variety of formats, but GraphViz lacks the capability to perform some basic tasks, e.g., accessing a network socket, receiving additional user input, or manipulating strings.&lt;/span&gt;&lt;/p&gt;For further reading: &lt;a href=&quot;http://en.wikipedia.org/wiki/Domain-specific_programming_language&quot;&gt;http://en.wikipedia.org/wiki/Domain-specific_programming_language&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/4301965344835970232/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/4301965344835970232' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/4301965344835970232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/4301965344835970232'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2007/05/dsl.html' title='D.S.L.'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-6948551459541405071</id><published>2007-04-20T16:44:00.001+05:30</published><updated>2009-03-27T14:56:13.539+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="What&#39;s New"/><title type='text'>Java Persistence API(JPA) in EJB 3.0</title><content type='html'>Java Persistence API (JPA) provides POJO (Plain Old Java Object) standard and object relational mapping (OR mapping) for data persistence among applications. Persistence, which deals with storing and retrieving of application data, can now be programmed with Java Persistence API starting from EJB 3.0 as a result of JSR 220. This API has borrowed many of the concepts and standards from leading persistence frameworks like Toplink (from Oracle) and Hibernate (from JBoss). One of the great benefits of JPA is that it is an independent API and can nicely integrate with J2EE as well as J2SE applications.Shunmuga Raja writes about JPA &lt;a href=&quot;http://www.javabeat.net/javabeat/ejb3/articles/2007/04/introduction_to_java_persistence_api_jpa_ejb_3_0_1&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.javabeat.net/javabeat/ejb3/articles/2007/04/introduction_to_java_persistence_api_jpa_ejb_3_0_1&quot;&gt;Java Persistence API(JPA) in EJB 3.0&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/6948551459541405071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/6948551459541405071' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/6948551459541405071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/6948551459541405071'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2007/04/whats-new.html' title='Java Persistence API(JPA) in EJB 3.0'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-9009388884334883364</id><published>2007-04-17T14:28:00.000+05:30</published><updated>2007-05-08T10:59:46.561+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tips and Tricks"/><title type='text'>Tips &amp; Tricks</title><content type='html'>&lt;strong&gt;Clear your memory with 1 Click!&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Tired of running a slow WindowsXP? Create this shortcut to clear your memory with 1 Click! easy, useful and handy. You&#39;ll be done in seconds...!&lt;br /&gt;&lt;br /&gt;create a desktop shortcut: %windir%system32/rundll32.exe advapi32.dll,ProcessIdleTasks&lt;br /&gt;&lt;br /&gt;name it: anynameyouwantclick it&lt;br /&gt;&lt;br /&gt;It just clears unallocated memory... It&#39;s a fundamental in computing; programs (whether they are running on XP, OS X, *nix) need to unallocate memory when they are finished with it... When they don&#39;t, thats when you get memory leaks. This shortcut will just clear _unallocated_ memory.</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/9009388884334883364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/9009388884334883364' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/9009388884334883364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/9009388884334883364'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2007/04/tips-tricks.html' title='Tips &amp; Tricks'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-1220774842600269126</id><published>2007-03-21T16:51:00.001+05:30</published><updated>2010-06-18T14:30:00.380+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Back To School"/><title type='text'>Java Core</title><content type='html'>&lt;strong&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Upcasting and Downcasting&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;A super class reference can be converted into a subclass reference but thissubclass reference is not useful to call the methods of any of the classes. This convention is known as &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Downcasting&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;We can convert the subclass reference to a superclass reference without using the cast poeration compiler because it will internally take care of the casting. This is known as &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Upcasting&lt;/span&gt;. &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Use Content-Disposition to Send a File&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;While we&#39;re on the subject of magic header incantations, servlet developers often struggle with finding the right header combination to send a browser a file that&#39;s intended for saving rather than viewing and thus triggers a &quot;Save As&quot; dialog. For the solution to this problem, I have some good news and some bad news.&lt;br /&gt;&lt;br /&gt;The bad news is that although the HTTP specification provides a mechanism for file downloads (see HTTP/1.1, Section 19.5.1), many browsers second-guess the server&#39;s directives and do what they think is best rather than what they&#39;re told. These browsers--including Microsoft Internet Explorer and Opera--look at the file extension and &quot;sniff&quot; the incoming content. If they see HTML or image content, they inline-display the file contents instead of offering a Save As dialog.[3] Turns out there&#39;s no 100% reliable way to download a file across all browsers. Perhaps, with this effort, programmers are more like alchemists than magicians, trying in vain to turn lead into gold.&lt;br /&gt;&lt;br /&gt;The good news is that the right combination of headers will download files well enough to be practical. With these special headers set, a compliant browser will open a Save As dialog, while a noncompliant browser will open the dialog for all content except HTML or image files. For these types it will display the content inline, where a user can use the menu to save the content. Example-1 shows the best technique for sending files.&lt;a name=&quot;ex3-9&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;Example-1: Sending a file for download // Set the headers.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;res.setContentType(&quot;application/x-download&quot;);&lt;br /&gt;res.setHeader(&quot;Content-Disposition&quot;, &quot;attachment; filename=&quot; + filename);&lt;br /&gt;// Send the file.&lt;br /&gt;OutputStream out = res.getOutputStream( );&lt;br /&gt;returnFile(filename, out); // Shown earlier in the chapter&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;First, set the Content-Type header to a nonstandard value such as application/x-download. It&#39;s very important that this header is something unrecognized by browsers because browsers often try to do something special when they recognize the content type.[4] Then set the Content-Disposition header to the value attachment; filename=foo, in which foo is substituted with the filename to be used by default in the Save As dialog. Finally, send the file content as bytes. The bytes can come from the filesystem or be dynamically generated.&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Using these headers, the file content in the response will be saved by most browsers or, in worst cases, displayed inline where the user can save the file. There&#39;s no standard way to download multiple files in one response.&lt;br /&gt;&lt;br /&gt;Finally, it can be useful to include the download file&#39;s name as extra path information to the servlet. The servlet can use the filename to learn which file to download, or it can ignore the extra path info. Either way, it&#39;s useful because the name appears to the browser as the name of the resource being retrieved, and browsers often use that name in the Save As dialog prompt. For example, instead of serving content from /servlet/FileDownload?fileid=5, serve it from /servlet/FileDownload/inventory.pdf?fileid=5.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;strong&gt;In which .jar file Object.class resides?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Object.class file is packed in &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;rt.jar&lt;/span&gt;, which is available at &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&lt;jdk&gt;&lt;/jdk&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;\jre\lib&lt;/span&gt;. All the core class libraries that come with the JDK are stored in a file named &quot;rt.jar&quot;. &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/1220774842600269126/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/1220774842600269126' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/1220774842600269126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/1220774842600269126'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2007/03/java-faqs.html' title='Java Core'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-475250513652365767</id><published>2007-02-16T11:39:00.001+05:30</published><updated>2010-07-02T14:27:05.311+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Articles"/><title type='text'></title><content type='html'>&lt;span style=&quot;font-size: 180%;&quot;&gt;Model Driven Architecture - MDA&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/475250513652365767/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/475250513652365767' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/475250513652365767'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/475250513652365767'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2007/02/model-driven-architecture-mda.html' title=''/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-2921676904459414786</id><published>2006-12-27T12:52:00.000+05:30</published><updated>2007-05-08T11:04:20.236+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Application Server FAQs"/><title type='text'>Weblogic Application Server FAQs</title><content type='html'>&lt;strong&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;WebLogic Server Application Classloading: How it works?&lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Overview of WebLogic Server Application Classloading&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;WebLogic Server classloading is centered on the concept of an application. An application is normally packaged in an Enterprise Archive (EAR) file containing application classes. Everything within an EAR file is considered part of the same application. The following may be part of an EAR or can be loaded as stand-alone applications:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;An Enterprise JavaBean (EJB) JAR file &lt;/li&gt;&lt;li&gt;A Web application WAR file &lt;/li&gt;&lt;li&gt;A resource adapter RAR file &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;If you deploy an EJB and a Web application separately, they are considered two applications. If they are deployed together within an EAR file, they are one application. You deploy modules together in an EAR file for them to be considered part of the same application.&lt;br /&gt;&lt;a name=&quot;wp1088610&quot;&gt;&lt;/a&gt;&lt;br /&gt;Every application receives its own classloader hierarchy; the parent of this hierarchy is the system classpath classloader. This isolates applications so that application A cannot see the classloaders or classes of application B. In hierarchy classloaders, no sibling or friend concepts exist. Application code only has visibility to classes loaded by the classloader associated with the application (or module) and classes that are loaded by classloaders that are ancestors of the application (or module) classloader. This allows WebLogic Server to host multiple isolated applications within the same JVM.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Application Classloader Hierarchy&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name=&quot;wp1073504&quot;&gt;&lt;/a&gt;WebLogic Server automatically creates a hierarchy of classloaders when an application is deployed. The root classloader in this hierarchy loads any EJB JAR files in the application. A child classloader is created for each Web application WAR file.&lt;br /&gt;&lt;a name=&quot;wp1073505&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Because it is common for Web applications to call EJBs, the WebLogic Server application classloader architecture allows JavaServer Page (JSP) files and servlets to see the EJB interfaces in their parent classloader. This architecture also allows Web applications to be redeployed without redeploying the EJB tier. In practice, it is more common to change JSP files and servlets than to change the EJB tier. &lt;/p&gt;&lt;p&gt;&lt;a name=&quot;wp1073629&quot;&gt;&lt;/a&gt;The following graphic illustrates this WebLogic Server application classloading concept.&lt;br /&gt;&lt;a name=&quot;wp1096906&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;strong&gt;Figure- 1 WebLogic Server Classloading &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&lt;/p&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&lt;a name=&quot;wp1096906&quot;&gt;&lt;/a&gt;&lt;div class=&quot;figure&quot; align=&quot;left&quot;&gt;&lt;img id=&quot;wp1096908&quot; style=&quot;WIDTH: 441px; HEIGHT: 252px&quot; height=&quot;309&quot; alt=&quot;WebLogic Server Classloading&quot; src=&quot;http://edocs.bea.com/wls/docs92/programming/wwimages/programming-07-1-1.gif&quot; width=&quot;512&quot; /&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name=&quot;wp1073629&quot;&gt;&lt;/a&gt;&lt;a name=&quot;wp1096937&quot;&gt;&lt;/a&gt;If your application includes servlets and JSPs that use EJBs:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Package the servlets and JSPs in a WAR file &lt;/li&gt;&lt;li&gt;Package the Enterprise JavaBeans in an EJB JAR file &lt;/li&gt;&lt;li&gt;Package the WAR and JAR files in an EAR file &lt;/li&gt;&lt;li&gt;Deploy the EAR file &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Although you could deploy the WAR and JAR files separately, deploying them together in an EAR file produces a classloader arrangement that allows the servlets and JSPs to find the EJB classes. If you deploy the WAR and JAR files separately, WebLogic Server creates sibling classloaders for them. This means that you must include the EJB home and remote interfaces in the WAR file, and WebLogic Server must use the RMI stub and skeleton classes for EJB calls, just as it does when EJB clients and implementation classes are in different JVMs.&lt;a name=&quot;pack015&quot;&gt;&lt;/a&gt; This concept is discussed in more detail in the next section &lt;a href=&quot;http://edocs.bea.com/wls/docs92/programming/classloading.html#wp1073506&quot;&gt;Application Classloading and Pass-by-Value or Reference&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;Note: The Web application classloader contains all classes for the Web application except for the JSP class. The JSP class obtains its own classloader, which is a child of the Web application classloader. This allows JSPs to be individually reloaded.&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;wp1083313&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Custom Module Classloader Hierarchies&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;You can create custom classloader hierarchies for an application allowing for better control over class visibility and reloadability. You achieve this by defining a classloader-structure element in the weblogic-application.xml deployment descriptor file.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;The following diagram illustrates how classloaders are organized by default for WebLogic applications. An application level classloader exists where all EJB classes are loaded. For each Web module, there is a separate child classloader for the classes of that module. &lt;/p&gt;&lt;p&gt;&lt;a name=&quot;wp1088755&quot;&gt;&lt;/a&gt;For simplicity, JSP classloaders are not described in the following diagram.&lt;br /&gt;&lt;a name=&quot;wp1084752&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;strong&gt;Figure-2 Standard Classloader Hierarchy &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class=&quot;figure&quot; align=&quot;left&quot;&gt;&lt;img id=&quot;wp1096908&quot; style=&quot;WIDTH: 415px; HEIGHT: 212px&quot; height=&quot;309&quot; alt=&quot;WebLogic Server Classloading&quot; src=&quot;http://edocs.bea.com/wls/docs92/programming/wwimages/ejbclassload.gif&quot; width=&quot;512&quot; /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;wp1083989&quot;&gt;&lt;/a&gt;This hierarchy is optimal for most applications, because it allows call-by-reference semantics when you invoke EJBs. It also allows Web modules to be independently reloaded without affecting other modules. Further, it allows code running in one of the Web modules to load classes from any of the EJB modules. This is convenient, as it can prevent a Web module from including the interfaces for EJBs that is uses. Note that some of those benefits are not strictly J2EE-compliant. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;a name=&quot;wp1084007&quot;&gt;&lt;/a&gt;The ability to create custom module classloaders provides a mechanism to declare alternate classloader organizations that allow the following: &lt;/p&gt;&lt;ul&gt;&lt;li&gt;Reloading individual EJB modules independently &lt;/li&gt;&lt;li&gt;Reloading groups of modules to be reloaded together &lt;/li&gt;&lt;li&gt;Reversing the parent child relationship between specific Web modules and EJB modules &lt;/li&gt;&lt;li&gt;Namespace separation between EJB modules &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;a name=&quot;wp1083960&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Declaring the Classloader Hierarchy&lt;/strong&gt;&lt;br /&gt;&lt;a name=&quot;wp1084087&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;You can declare the classloader hierarchy in the WebLogic-specific application deployment descriptor weblogic-application.xml.&lt;br /&gt;&lt;a name=&quot;wp1084271&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The DTD for this declaration is as follows:&lt;br /&gt;&lt;/p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&lt;!--&lt;!ELEMENT classloader-structure (module-ref*, classloader-structure*)&gt;&lt;/span&gt;&lt;a name=&quot;wp1083964&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&lt;!ELEMENT module-ref (module-uri)&gt;&lt;/span&gt;&lt;a name=&quot;wp1083965&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;!ELEMENT module-uri (#PCDATA)&gt;--&gt;&lt;ul&gt;&lt;li&gt;&amp;lt;!ELEMENT classloader-structure (module-ref*, classloader-structure*&amp;gt;&lt;/li&gt;&lt;li&gt;&amp;lt;!ELEMENT module-ref (module-uri)&amp;gt;&lt;/li&gt;&lt;li&gt;&amp;lt;!ELEMENT module-uri (#PCDATA)&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;a name=&quot;wp1088782&quot;&gt;&lt;/a&gt;&lt;p&gt;The top-level element in weblogic-application.xml includes an optional classloader-structure element. If you do not specify this element, then the standard classloader is used. Also, if you do not include a particular module in the definition, it is assigned a classloader, as in the standard hierarchy. That is, EJB modules are associated with the application Root classloader, and Web application modules have their own classloaders.&lt;br /&gt;&lt;/p&gt;&lt;a name=&quot;wp1084327&quot;&gt;&lt;/a&gt;&lt;p&gt;The classloader-structure element allows for the nesting of classloader-structure stanzas, so that you can describe an arbitrary hierarchy of classloaders. There is currently a limitation of three levels. The outermost entry indicates the application classloader. For any modules not listed, the standard hierarchy is assumed. &lt;a name=&quot;wp1088979&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Note: JSP classloaders are not included in this definition scheme. JSPs are always loaded into a classloader that is a child of the classloader associated with the Web module to which it belongs.&lt;br /&gt;&lt;a name=&quot;wp1086197&quot;&gt;&lt;/a&gt;For more information on the DTD elements, refer to &lt;a href=&quot;http://edocs.bea.com/wls/docs92/programming/app_xml.html&quot;&gt;Enterprise Application Deployment Descriptor Elements.&lt;/a&gt;&lt;br /&gt;&lt;a name=&quot;wp1084415&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The following is an example of a classloader declaration (defined in the classloader-structure element in weblogic-application.xml):&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&amp;lt;classloader-structure&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&amp;lt;module-ref&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&amp;lt;module-uri&amp;gt;ejb1.jar&amp;lt;/module-uri&amp;gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&amp;lt;/module-ref&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&amp;lt;module-ref&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&amp;lt;module-uri&amp;gt;web3.war&amp;lt;/module-uri&amp;gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&amp;lt;/module-ref&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&amp;lt;classloader-structure&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&amp;lt;module-ref&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&amp;lt;module-uri&amp;gt;web1.war&amp;lt;/module-uri&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&amp;lt;/module-ref&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&amp;lt;/classloader-structure&amp;gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&amp;lt;/classloader-structure&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;classloader-structure&gt;&lt;/span&gt;&lt;a name=&quot;wp1090436&quot;&gt;&lt;/a&gt;The organization of the nesting indicates the classloader hierarchy. The above stanza leads to a hierarchy shown in the following diagram.&lt;br /&gt;&lt;a name=&quot;wp1084652&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;strong&gt;Figure-3 Example Classloader Hierarchy &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class=&quot;figure&quot; align=&quot;left&quot;&gt;&lt;img id=&quot;wp1096908&quot; style=&quot;WIDTH: 347px; HEIGHT: 291px&quot; height=&quot;309&quot; alt=&quot;WebLogic Server Classloading&quot; src=&quot;http://edocs.bea.com/wls/docs92/programming/wwimages/newhierarchy.gif&quot; width=&quot;512&quot; /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;User-Defined Classloader Restrictions&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;a name=&quot;wp1085039&quot;&gt;&lt;/a&gt;User-defined classloader restrictions give you better control over what is reloadable and provide inter-module class visibility. This feature is primarily for developers. It is useful for iterative development, but the reloading aspect of this feature is not recommended for production use, because it is possible to corrupt a running application if an update includes invalid elements. Custom classloader arrangements for namespace separation and class visibility are acceptable for production use. However, programmers should be aware that the J2EE specifications say that applications should not depend on any given classloader organization.&lt;br /&gt;&lt;a name=&quot;wp1085037&quot;&gt;&lt;/a&gt;Some classloader hierarchies can cause modules within an application to behave more like modules in two separate applications. For example, if you place an EJB in its own classloader so that it can be reloaded individually, you receive call-by-value semantics rather than the call-by-reference optimization BEA provides in our standard classloader hierarchy. Also note that if you use a custom hierarchy, you might end up with stale references. Therefore, if you reload an EJB module, you should also reload calling modules.&lt;br /&gt;&lt;a name=&quot;wp1084934&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;There are some restrictions to creating user-defined module classloader hierarchies; these are discussed in the following sections.&lt;br /&gt;&lt;a name=&quot;wp1084961&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;Servlet Reloading Disabled&lt;/em&gt;&lt;br /&gt;&lt;a name=&quot;wp1084998&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;If you use a custom classloader hierarchy, servlet reloading is disabled for Web applications in that particular application.&lt;br /&gt;&lt;a name=&quot;wp1085105&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;Nesting Depth&lt;br /&gt;&lt;/em&gt;&lt;a name=&quot;wp1085440&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Nesting is limited to three levels (including the application classloader). Deeper nestings lead to a deployment exception.&lt;br /&gt;&lt;a name=&quot;wp1085066&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;Module Types&lt;/em&gt;&lt;br /&gt;&lt;a name=&quot;wp1085508&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Custom classloader hierarchies are currently restricted to Web and EJB modules.&lt;br /&gt;&lt;a name=&quot;wp1085257&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;Duplicate Entries&lt;/em&gt;&lt;br /&gt;&lt;a name=&quot;wp1085566&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Duplicate entries lead to a deployment exception.&lt;br /&gt;&lt;a name=&quot;wp1085284&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;Interfaces &lt;/em&gt;&lt;br /&gt;&lt;a name=&quot;wp1085603&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The standard WebLogic Server classloader hierarchy makes EJB interfaces available to all modules in the application. Thus other modules can invoke an EJB, even though they do not include the interface classes in their own module. This is possible because EJBs are always loaded into the root classloader and all other modules either share that classloader or have a classloader that is a child of that classloader.&lt;br /&gt;&lt;a name=&quot;wp1085626&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;With the custom classloader feature, you can configure a classloader hierarchy so that a callee&#39;s classes are not visible to the caller. In this case, the calling module must include the interface classes. This is the same requirement that exists when invoking on modules in a separate application.&lt;br /&gt;&lt;a name=&quot;wp1085312&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;Call-by-Value Semantics&lt;/em&gt;&lt;br /&gt;&lt;a name=&quot;wp1085660&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The standard classloader hierarchy provided with WebLogic Server allows for calls between modules within an application to use call-by-reference semantics. This is because the caller is always using the same classloader or a child classloader of the callee. With this feature, it is possible to configure the classloader hierarchy so that two modules are in separate branches of the classloader tree. In this case, call-by-value semantics are used.&lt;br /&gt;&lt;a name=&quot;wp1085360&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;In-Flight Work&lt;/em&gt;&lt;br /&gt;&lt;a name=&quot;wp1090644&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Be aware that the classloader switch required for reloading is not atomic across modules. In fact, updates to applications in general are not atomic. For this reason, it is possible that different in-flight operations (operations that are occurring while a change is being made) might end up accessing different versions of classes depending on timing.&lt;br /&gt;&lt;a name=&quot;wp1090645&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;Development Use Only&lt;/em&gt;&lt;br /&gt;&lt;/p&gt;&lt;a name=&quot;wp1085749&quot;&gt;&lt;/a&gt;&lt;p&gt;The development-use-only feature is intended for development use. Because updates are not atomic, this feature is not suitable for production use.&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;module-ref&gt;&lt;/span&gt;&lt;a name=&quot;wp1090437&quot;&gt;&lt;/a&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;/MODULE-REF&gt;&lt;/span&gt;&lt;a name=&quot;wp1090463&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;/CLASSLOADER-STRUCTURE&gt;&lt;/span&gt;&lt;a name=&quot;wp1090464&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Individual EJB Classloader for Implementation Classes&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;wp1086003&quot;&gt;&lt;/a&gt;WebLogic Server allows you to reload individual EJB modules without requiring you to reload other modules at the same time and having to redeploy the entire EJB module. This feature is similar to how JSPs are currently reloaded in the WebLogic Server servlet container.&lt;br /&gt;&lt;a name=&quot;wp1086044&quot;&gt;&lt;/a&gt;Because EJB classes are invoked through an interface, it is possible to load individual EJB implementation classes in their own classloader. This way, these classes can be reloaded individually without having to redeploy the entire EJB module. Below is a diagram of what the classloader hierarchy for a single EJB module would look like. The module contains two EJBs (Foo and Bar). This would be a sub-tree of the general application hierarchy described in the previous section. &lt;/p&gt;&lt;p&gt;&lt;a name=&quot;wp1086005&quot;&gt;&lt;/a&gt;&lt;strong&gt;&lt;span style=&quot;font-size:78%;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Figure-4 Example Classloader Hierarchy for a Single EJB Module&lt;/span&gt; &lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class=&quot;figure&quot; align=&quot;left&quot;&gt;&lt;img id=&quot;wp1096908&quot; style=&quot;WIDTH: 424px; HEIGHT: 293px&quot; height=&quot;309&quot; alt=&quot;WebLogic Server Classloading&quot; src=&quot;http://edocs.bea.com/wls/docs92/programming/wwimages/ejb.gif&quot; width=&quot;512&quot; /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;a name=&quot;wp1086233&quot;&gt;&lt;/a&gt;To perform a partial update of files relative to the root of the exploded application, use the following command line:&lt;br /&gt;&lt;a name=&quot;wp1086317&quot;&gt;&lt;/a&gt;&lt;a name=&quot;wp1086234&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;color:#ff0000;&quot;&gt;java weblogic.Deployer -adminurl url -user user -password password &lt;/span&gt;&lt;a name=&quot;wp1086235&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;-name myapp -redeploy myejb/foo.class &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;a name=&quot;wp1086306&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;After the -redeploy command, you provide a list of files relative to the root of the exploded application that you want to update. This might be the path to a specific element (as above) or a module (or any set of elements and modules). For example:&lt;br /&gt;&lt;a name=&quot;wp1086392&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;color:#ff0000;&quot;&gt;java weblogic.Deployer -adminurl url -user user -password password &lt;/span&gt;&lt;a name=&quot;wp1086423&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;font-size:85%;color:#ff0000;&quot;&gt;-name myapp -redeploy mywar myejb/foo.class anotherejb&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;a name=&quot;wp1086437&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Given a set of files to be updated, the system tries to figure out the minimum set of things it needs to redeploy. Redeploying only an EJB impl class causes only that class to be redeployed. If you specify the whole EJB (in the above example, anotherejb) or if you change and update the EJB home interface, the entire EJB module must be redeployed.&lt;br /&gt;&lt;a name=&quot;wp1086476&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Depending on the classloader hierarchy, this redeployment may lead to other modules being redeployed. Specifically, if other modules share the EJB classloader or are loaded into a classloader that is a child to the EJB&#39;s classloader (as in the WebLogic Server standard classloader module) then those modules are also reloaded.&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;/CLASSLOADER-STRUCTURE&gt;&lt;/span&gt;&lt;a name=&quot;wp1084471&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;Mild Deployment - Subset of Hot Deployment&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;From last few days I was trying to incorporate Hot Deployment functionality into my application, to reduce the deployment time and also to elevate the performance. Due to some flaws in the design, I was not able to incorporate it “&lt;em&gt;PROPERLY&lt;/em&gt;”. Yes you heard correct - “not Properly”. &lt;/p&gt;&lt;p&gt;Ok let me take a step back. Let’s first answer the question – &lt;em&gt;What is Hot Deployment&lt;/em&gt;? In very simple terms – Hot deployment is a feature which allows developers to deploy .class/.jsp files without shutting down the server. To see the changes you just have to refresh the application.&lt;br /&gt;&lt;br /&gt;JSPs can be hot deployed easily. You just have to replace the newer version of your JSP in the build folder. Why? Answer is very simple. There is a separate Classloader for loading Web Application.&lt;br /&gt;&lt;br /&gt;Note: Whenever an application is deployed in the Weblogic Application Server using the exploded (-x) option, a temporary &lt;em&gt;build folder&lt;/em&gt; is generated.&lt;br /&gt;&lt;br /&gt;But what about .class files? Once you make some changes in a .java file what process you follow? Usually we follow these steps:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Fist shutdown the server.&lt;/li&gt;&lt;li&gt;Compile the file.&lt;/li&gt;&lt;li&gt;Deploy the application again.&lt;/li&gt;&lt;li&gt;Then in the end start the application server.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;If you observe, whenever you deploy the application, it deletes the domain folder and creates it from the scratch. This process usually takes around 3-5 minutes. domain folder also contains JSPs. So if you have hot deployed any of your JSPs, all changes are gone.&lt;br /&gt;&lt;br /&gt;Note: &lt;em&gt;domain folder&lt;/em&gt; is also a temporary folder under the build folder. domain folder usually contains compiled JSPs.&lt;br /&gt;&lt;br /&gt;To address these issues, I came up with a new feature – “Mild Deployment”. It is a kind of Hot Deployment, but in this case you have to shutdown the application server. This feature will eliminate the re-deployment of the application and will save lot of time.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;What is Mild Deployment&lt;/em&gt;? Before answering this question let me give you some brief about Weblogic Deployment Process. There are two ways to deploy an application in Weblogic – &lt;em&gt;archival&lt;/em&gt; deployment and &lt;em&gt;exploded&lt;/em&gt; deployment. The only difference between these two is, in the later one the EAR file is exploded into the appropriate directory structure.&lt;/p&gt;&lt;p&gt;Now coming back to the original question – What is Mild deployment? In the Mild Deployment we replace the respective JAR files, which are generated temporarily in the build folder as a result of explosion of the EAR file. This feature does not work if the application is deployed using the archival mode.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/2921676904459414786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/2921676904459414786' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/2921676904459414786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/2921676904459414786'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2006/12/weblogic-application-server-faqs.html' title='Weblogic Application Server FAQs'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-6989070835651118685</id><published>2006-12-27T12:45:00.000+05:30</published><updated>2007-03-22T13:56:42.937+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="EJB FAQs"/><title type='text'>EJB FAQs</title><content type='html'>What is &lt;em&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;ejbPostCreate()&lt;/span&gt;&lt;/em&gt; used for?&lt;br /&gt;&lt;br /&gt;The usage of the &lt;em&gt;ejbPostCreate()&lt;/em&gt; method has always been a point of confusion for many Enterprise JavaBeans (EJB) technology developers, but is very easy to explain. During initialization of an Entity Bean, the required &lt;em&gt;ejbCreate()&lt;/em&gt; method of the bean is called and it&#39;s context is set. Finally the &lt;em&gt;ejbPostCreate()&lt;/em&gt; method corresponding to the &lt;em&gt;ejbCreate(&lt;/em&gt;) method is called. During the call to &lt;em&gt;ejbCreate(&lt;/em&gt;) the bean knows nothing about itself or it&#39;s context. It is therefore unable to either pass a reference to itself, to another Entity bean, or even to access its own Primary key. In &lt;em&gt;ejbPostCreate()&lt;/em&gt; the bean has access to its own remote interface and it&#39;s own Primary Key via the EntityContext and it&#39;s &lt;em&gt;getEJBObject()&lt;/em&gt; and &lt;em&gt;getPrimaryKey()&lt;/em&gt; methods. This is particularly useful for establishing relationships with other Entity Beans.</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/6989070835651118685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/6989070835651118685' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/6989070835651118685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/6989070835651118685'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2006/12/ejb-faqs.html' title='EJB FAQs'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7900835119661228409.post-892539275361181060</id><published>2006-12-18T12:28:00.002+05:30</published><updated>2010-07-06T09:15:21.149+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Introduction"/><title type='text'>Introduction</title><content type='html'>&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi31rTCmKOFK8ZWN3TJXlcTZbS5QxUoxUowShvmxxW6Vn8qFFragyKT64oCshBTsk0HoWHGlbzfj9YHroREaEDy-uL3NuHqsEHf_wIHIzheqiVBIPjWE_mPP1n1viDMbQXLOZjMKSo3SxQ/s1600-h/P1080602.JPG&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5009773504824765810&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi31rTCmKOFK8ZWN3TJXlcTZbS5QxUoxUowShvmxxW6Vn8qFFragyKT64oCshBTsk0HoWHGlbzfj9YHroREaEDy-uL3NuHqsEHf_wIHIzheqiVBIPjWE_mPP1n1viDMbQXLOZjMKSo3SxQ/s200/P1080602.JPG&quot; style=&quot;float: right; margin: 0px 0px 10px 10px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPqXaOOHLcYPhU7DEpj7h6n48YzEWhso-Qjm_zd5sGjyqcjAB63JV-iP_LqQSnLm6Z4CCir3CKEkAJD8O4toPj1gLuxQZvchsDXD25wvnduYRBWkPYzwmy-NvtiZ6ZwuDqD68pNLraHlM/s1600-h/P1080602.JPG&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Before logging any error, let me first introduce Yash Garg.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;NameNotFoundException:&lt;/i&gt; Name &lt;i&gt;Yash Garg&lt;/i&gt; not found in the blogger&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Solution:&lt;/i&gt; My name is Yash Garg, age 29 years. Working as a Principal Engineer in &lt;a href=&quot;http://www.emptoris.com/&quot;&gt;Emptoris Technologies&lt;/a&gt; . I have been working on J2EE technologies from last 5 years.&lt;br /&gt;
&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;ObjectNotFoundException:&lt;/i&gt; Object My Error Log not found in the blogger&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Solution:&lt;/i&gt; This is my first post. The idea behind creating this blog is to share my views with rest of the world, may be with the universe.&lt;br /&gt;
&lt;br /&gt;
Every day we encounter lot of errors while compiling or running applications. The most common is NullPointerException. So when you see this sort of error, what is your approach? Yes &quot;&lt;i&gt;APPROACH&lt;/i&gt;&quot;! This is the word I like to share with you people.&lt;br /&gt;
&lt;br /&gt;
Using this blog I will be discussing different kind of approaches to handle different kind of &lt;i&gt;ERRORS&lt;/i&gt;. Here I will list all the errors i have encountered so far along with the approach i took to resolve.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myerrorslog.blogspot.com/feeds/892539275361181060/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7900835119661228409/892539275361181060' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/892539275361181060'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7900835119661228409/posts/default/892539275361181060'/><link rel='alternate' type='text/html' href='http://myerrorslog.blogspot.com/2006/12/introduction.html' title='Introduction'/><author><name>Yash Garg</name><uri>http://www.blogger.com/profile/17852733607302184071</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjQ1vuHEuom4HMkwhKrGLB5-r0pe_LGnJojGeHYurAxGL9QBh8H_XdW4XmGTo9fBqYfZAYx4j-ApUUBIf8uRSFpW1gcwinCBt_8BjV_M9QPyTNyaeboc6xuJEJVJoo2Q/s220/DSC00207.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi31rTCmKOFK8ZWN3TJXlcTZbS5QxUoxUowShvmxxW6Vn8qFFragyKT64oCshBTsk0HoWHGlbzfj9YHroREaEDy-uL3NuHqsEHf_wIHIzheqiVBIPjWE_mPP1n1viDMbQXLOZjMKSo3SxQ/s72-c/P1080602.JPG" height="72" width="72"/><thr:total>0</thr:total></entry></feed>