<?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-6182869092006240514</id><updated>2024-10-04T19:02:15.028-07:00</updated><title type='text'>Hot cup with JAVA Technologies!!</title><subtitle type='html'>Java, Struts, Spring, Hibernate, Unix,IT, Software, Jobs, Interview, Aptitude, Learning, Algorithms</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>61</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-2819524247673933270</id><published>2010-11-19T17:54:00.000-08:00</published><updated>2010-11-19T17:54:33.441-08:00</updated><title type='text'>Quick View - Java 7 Features</title><content type='html'>1. Up-gradation to class loader architecture to avoid deadlocks in non-hierarchical class-loader topologies.&lt;br /&gt;
2. A method has been added to free the underlying resources, such as open files, held by a URLClassLoader.&lt;br /&gt;
3. A lightweight fork/join framework, flexible and reusable synchronization barriers, transfer queues, a concurrent-reference HashMap, and thread-local pseudo-random number generators.&lt;br /&gt;
4. Upgraded to supported version of Unicode 6.0 for more from internationalization.&lt;br /&gt;
5. the java.util.Locale class to support IETF BCP 47 and UTR 35 now.&lt;br /&gt;
6. Now there will be a two separate locale for user and user-interface.&lt;br /&gt;
7. New APIs for filesystem access, scalable asynchronous I/O operations, socket-channel binding and configuration, and multicast datagrams&lt;br /&gt;
8. New fully functional file system provider NIO.2 for zip/jar archiving.&lt;br /&gt;
9. JDBC upgraded to 4.1 and Rowset to 1.1&lt;br /&gt;
10. XML stack is upgraded to new stable version for more on web.&lt;br /&gt;
11. JSR 292 providing support for dynamically typed language.</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/2819524247673933270/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/11/quick-view-java-7-features.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/2819524247673933270'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/2819524247673933270'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/11/quick-view-java-7-features.html' title='Quick View - Java 7 Features'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-3070353548170131788</id><published>2010-11-18T06:13:00.000-08:00</published><updated>2010-11-18T06:13:07.932-08:00</updated><title type='text'>OutOfMemoryError: PermGen space while reloading webapp in tomcat</title><content type='html'>This annoying error of PermGen space OOMs when reloading the webapp in tomact is because in tomcat the class loader only loads the classes and this class loader and loaded classes are never garbage collected. Each time you reload your webapp, copies of classes will be added to memory, basically the permanent heap space used by tomcat. This eventually makes tomcat run out of memory to further carry out operation.&lt;br /&gt;
&lt;br /&gt;
This is common and can happen with other containers also until unless in some version the owner have made changes to take care of this. Try reloading the application again and again until unless your container cry of Out of Memory Error. What we can do in such a situation is to restart the container which basically clean up the heap and load the application again.&lt;br /&gt;
&lt;br /&gt;
Additionally try no putting your JDBC and commons jar in the WEB-INF. Instead you can put them in the TOMCAT-HOME/common/lib folder because these are already bootstrapped by tomcat. If you face issue of &#39;No suitable driver&#39; Exception after placing your jdbc jar in tomcat common/lib, try adding you jndi db definition in context.xml like&lt;br /&gt;
&amp;lt;\Context path=&quot;/test&quot; reloadable=&quot;true&quot; debug=&quot;1&quot;&amp;gt;&lt;br /&gt;
&amp;lt;\Resource name=&quot;jdbc/db&quot; auth=&quot;Container&quot; type=&quot;javax.sql.DataSource&quot; maxActive=&quot;30&quot; maxIdle=&quot;3&quot;&lt;br /&gt;
maxWait=&quot;10000&quot; username=&quot;testing&quot; password=&quot;testing&quot; driverClassName=&quot;net.sourceforge.jtds.jdbc.Driver&quot; url=&quot;jdbc:testdburl;lastupdatecount=true&quot; /&amp;gt;</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/3070353548170131788/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/11/outofmemoryerror-permgen-space-while.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/3070353548170131788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/3070353548170131788'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/11/outofmemoryerror-permgen-space-while.html' title='OutOfMemoryError: PermGen space while reloading webapp in tomcat'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-4787061317767600187</id><published>2010-10-31T07:00:00.000-07:00</published><updated>2010-10-31T07:00:01.081-07:00</updated><title type='text'>equals and hashcode</title><content type='html'>Object equals will just compare references and hashcode is native which always return difference integer even if objects are same but different instances. So of you override equals and not hashcode for any object being used as a key in hashmap, then I will not get value corresponding to key because it wont be able to find hashcode for new instance of key. As it will look into the wrong bucket (new bucket) if I override hashcode and not equals, even there I wont be able to get the value because I can find the bucket but objects equal check references which will be different for stored object and my key object (new instance of old key object).</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/4787061317767600187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/equals-and-hashcode.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/4787061317767600187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/4787061317767600187'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/equals-and-hashcode.html' title='equals and hashcode'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-8711966882879641680</id><published>2010-10-31T06:52:00.000-07:00</published><updated>2010-10-31T06:52:16.264-07:00</updated><title type='text'>DB Connection class</title><content type='html'>DriverManager.getConnection (url, user, pwd).getClass().getName().equals(&quot;java.sql.Connection&quot;) = false&lt;br /&gt;
&lt;br /&gt;
This is false because left hand side will return a class of the underlying database connection class i.e. oracle.jdbc.driver.OracleConnection in case of oracle. So this will be a instance of java.sql.Connection but can not be equal.</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/8711966882879641680/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/db-connection-class.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/8711966882879641680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/8711966882879641680'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/db-connection-class.html' title='DB Connection class'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-3305741617798631727</id><published>2010-10-31T06:45:00.000-07:00</published><updated>2010-10-31T06:45:25.137-07:00</updated><title type='text'>Cut rectangular cake half</title><content type='html'>Given a rectangular cake with rectangular piece removed (any size, any orientation), how would you cut remainder cake in two equal haves with one straight cut of knife.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiegR5DoRxtOht31cnFNySji5ok0ABV99k-wfEGetJSen2rTAcPwgusv8Q-Tf5G1R0yMnWzW-BGoJQMoZZGZ40JcwGQo0g1TTzKqs_XG8cO00zoXLKKJ-bxhjG4999EcrhjBC6m7UMosEb/s1600/rectangular+piece.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;133&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiegR5DoRxtOht31cnFNySji5ok0ABV99k-wfEGetJSen2rTAcPwgusv8Q-Tf5G1R0yMnWzW-BGoJQMoZZGZ40JcwGQo0g1TTzKqs_XG8cO00zoXLKKJ-bxhjG4999EcrhjBC6m7UMosEb/s200/rectangular+piece.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Cut the piece horizontally&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqF7RsJevuzgvjdXxRlCsRQjGEYAxEjDAvUTshaoIwJa7YFBXdhBEgnn_VsBF5OekZgF6E8-W4hRArFdVR4WdSM0afgnh8YNNdX-sGnmAAsJ6mBv3HP4W4uAz1vuPfiHCRfKf9q2v1ueaX/s1600/cut+half.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;133&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqF7RsJevuzgvjdXxRlCsRQjGEYAxEjDAvUTshaoIwJa7YFBXdhBEgnn_VsBF5OekZgF6E8-W4hRArFdVR4WdSM0afgnh8YNNdX-sGnmAAsJ6mBv3HP4W4uAz1vuPfiHCRfKf9q2v1ueaX/s200/cut+half.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/3305741617798631727/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/cut-rectangular-cake-half.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/3305741617798631727'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/3305741617798631727'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/cut-rectangular-cake-half.html' title='Cut rectangular cake half'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiegR5DoRxtOht31cnFNySji5ok0ABV99k-wfEGetJSen2rTAcPwgusv8Q-Tf5G1R0yMnWzW-BGoJQMoZZGZ40JcwGQo0g1TTzKqs_XG8cO00zoXLKKJ-bxhjG4999EcrhjBC6m7UMosEb/s72-c/rectangular+piece.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-982056888556679320</id><published>2010-10-31T06:30:00.000-07:00</published><updated>2010-10-31T06:30:27.753-07:00</updated><title type='text'>Serializable Singleton</title><content type='html'>In a class write below code to prevent singleton class from losing its behavior if you make it serializable.&lt;br /&gt;
&lt;br /&gt;
protected Object readResolve(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return singletonObj; &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Deserialization creates another object instance, so to avoid that situation this needs to be done.</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/982056888556679320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/serializable-singleton.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/982056888556679320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/982056888556679320'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/serializable-singleton.html' title='Serializable Singleton'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-1322660004784942266</id><published>2010-10-31T05:36:00.000-07:00</published><updated>2010-10-31T05:36:13.204-07:00</updated><title type='text'>Java Threading</title><content type='html'>public static void myMethod(){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; synchronized(this){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //do stuff&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
This will not get a class level lock, many threads can enter this static method of class and with individual object lock can execute code in it.&lt;br /&gt;
&lt;br /&gt;
public static synchronized void myMethod() {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //do stuff&lt;br /&gt;
}&lt;br /&gt;
-----is equivalent to-----&lt;br /&gt;
public void myMethod(){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; synchronized(MyClass.class){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //do stuff&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
In both the case, threads will obtain a class level lock butt there will just be a difference of timing for how long lock is being obtained.&lt;br /&gt;
&lt;br /&gt;
1. Threads that synchronize on the same object will block each other. Threads that synchronize on different objects will not.&lt;br /&gt;
2. A static synchronized method and a non-static synchronized method will not block each other, ever. The static method locks on a class instance while non-static method locks on this instance these actions do not interfere with each other at all.&lt;br /&gt;
3. Threads calling static synchronized methods in the same class will always block each other - they all lock the same class instance.&lt;br /&gt;
4. Threads calling non-static synchronized methods in the same class will only block each other if they are invoked using same instance.&lt;br /&gt;
5. A thread can acquire more that one lock. A thread can enter a synchronized method, acquiring a lock and then immediately invoke a synchronized method on a different object, acquiring that locak as well. A thread acquires a lock and then attempts to call a synchronized method on the same object, no problem because thread already have lock of this object.&lt;br /&gt;
6. If a class has both synchronized and non-synchronized methods, multiple threads can still access the class&#39;s non-synchronized methods.&lt;br /&gt;
&lt;br /&gt;
Thread Join-&lt;br /&gt;
If you have a thread B that can&#39;t do its work until another thread A has completed its work, then you want B to join thread A.&lt;br /&gt;
This means that thread B will not become runnable until thread A has finished.&lt;br /&gt;
Thread t = new Thread();&lt;br /&gt;
t.start();&lt;br /&gt;
t.join();&lt;br /&gt;
This code take currently running thread and joins it to the end of thread t. Current thread become runnable after thread t is no longer alive.</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/1322660004784942266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/java-threading.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/1322660004784942266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/1322660004784942266'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/java-threading.html' title='Java Threading'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-3690349090527392508</id><published>2010-10-31T04:55:00.000-07:00</published><updated>2010-10-31T04:55:30.490-07:00</updated><title type='text'>Fibonacci</title><content type='html'>public void fibonacci(){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; int curr = 1;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; int prv = 0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; int prvHolder=0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int c = 0; c &amp;lt;= 30; c++){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sysout (curr);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prvHolder=prv;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prv=curr;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curr += prvHolder;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/3690349090527392508/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/fibonacci.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/3690349090527392508'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/3690349090527392508'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/fibonacci.html' title='Fibonacci'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-7415320553654575778</id><published>2010-10-31T04:50:00.000-07:00</published><updated>2010-10-31T04:50:38.760-07:00</updated><title type='text'>Prime factorization</title><content type='html'>public void primeFactor (int num){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; List factors = new ArrayList();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 2; i &amp;lt;= n; i++){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (n % i == 0){&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; factors.add(i);&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; n /= i;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/7415320553654575778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/prime-factorization.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/7415320553654575778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/7415320553654575778'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/prime-factorization.html' title='Prime factorization'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-2089359742670259105</id><published>2010-10-31T04:47:00.000-07:00</published><updated>2010-10-31T04:47:36.745-07:00</updated><title type='text'>Greatest Common Divisor</title><content type='html'>public int gcd (int p, int q){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (q=-=0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return p;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp; return gcd (q, p%q);&lt;br /&gt;
}</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/2089359742670259105/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/greatest-common-divisor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/2089359742670259105'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/2089359742670259105'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/greatest-common-divisor.html' title='Greatest Common Divisor'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-7760264799134549791</id><published>2010-10-31T04:45:00.000-07:00</published><updated>2010-10-31T04:45:14.053-07:00</updated><title type='text'>Annotation</title><content type='html'>It releives java developer from sumbersome configuration. Declarative programming style - programmer says what should be done &amp;amp; tools emit the code to do it. These are meta-tag information.</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/7760264799134549791/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/annotation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/7760264799134549791'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/7760264799134549791'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/annotation.html' title='Annotation'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-112142387919109672</id><published>2010-10-31T04:43:00.000-07:00</published><updated>2010-10-31T04:43:25.059-07:00</updated><title type='text'>DisplayTag</title><content type='html'>&amp;lt;display:table export=&quot;true&quot; is=&quot;data&quot; name=&quot;sessionScope.UserForm.forbesList&quot; requestURI=&quot;/userAction.do&quot; poagesize=&quot;10&quot; &amp;gt;&lt;br /&gt;
&amp;lt;display:column property=&quot;rank&quot; title=&quot;Rank&quot; sortable=&quot;true&quot; /&amp;gt;&lt;br /&gt;
....&lt;br /&gt;
&amp;lt;/display:table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
export - to export table data as excel, csv or xml&lt;br /&gt;
sortable - makes column sortable by providing clickable title&lt;br /&gt;
pagesize - for pagination</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/112142387919109672/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/displaytag.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/112142387919109672'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/112142387919109672'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/displaytag.html' title='DisplayTag'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-5925115178424942847</id><published>2010-10-31T04:01:00.000-07:00</published><updated>2010-10-31T04:33:03.252-07:00</updated><title type='text'>Hibernate mapping</title><content type='html'>Event table (LocationID - FK, EventID - PK)&lt;br /&gt;
Attendee Table (AttendeeID - PK)&lt;br /&gt;
SpeakerID (SpeakerID - PK, EventID - FK)&lt;br /&gt;
Event_Attendee (EventID, AttendeeID)&lt;br /&gt;
&lt;br /&gt;
An event can have many attendee and speakers. An attendee can attend many events. One location can also have many events.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;class name=&quot;Event&quot; table=&quot;events&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;id name=&quot;id&quot; column=&quot;uid&quot; type=&quot;long&quot;&amp;gt;&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;lt;generator class=&quot;increment&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/id&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;name&quot; type=&quot;string&quot; length=&quot;100&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;many-to-one name=&quot;location&quot; column=&quot;locationID&quot; class=&quot;Location&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;set name=&quot;speakers&quot; cascade=&quot;all&quot;&amp;gt;&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;lt;key column=&quot;eventID&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;one-to-many class=Speakers&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/set&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;set name=&quot;attendee&quot; table=&quot;event_attendee&quot; cascade=&quot;all&quot;&amp;gt;&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;lt;key column=&quot;eventID&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;many-to-many column=&quot;AttendeeID&quot; class=Attendee&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/set&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;lt;/hibernate-mapping&amp;gt;</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/5925115178424942847/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/hibernate-mapping.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/5925115178424942847'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/5925115178424942847'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/hibernate-mapping.html' title='Hibernate mapping'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-6050810427707587395</id><published>2010-10-31T03:44:00.001-07:00</published><updated>2010-10-31T03:44:56.010-07:00</updated><title type='text'>Find circular linked list</title><content type='html'>Start with two pointers. Increase one ptr by 1 and second ptr by 2. If they meet then list is circular.</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/6050810427707587395/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/find-circular-linked-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/6050810427707587395'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/6050810427707587395'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/find-circular-linked-list.html' title='Find circular linked list'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-6038772511033857456</id><published>2010-10-31T03:42:00.000-07:00</published><updated>2010-10-31T03:42:25.539-07:00</updated><title type='text'>Reverse a string</title><content type='html'>To reverse a string in java, tokenize the string and starting printing from len-1 to 0.</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/6038772511033857456/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/reverse-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/6038772511033857456'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/6038772511033857456'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/reverse-string.html' title='Reverse a string'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-7010662311472697569</id><published>2010-10-31T03:39:00.001-07:00</published><updated>2010-10-31T03:39:39.339-07:00</updated><title type='text'>Summing column value in SQL</title><content type='html'>To sum the columns&#39; of a record in table use &#39;+&#39; operator like -&lt;br /&gt;
&lt;i&gt;select col1+col2 from table test&lt;/i&gt;</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/7010662311472697569/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/10/summing-column-value-in-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/7010662311472697569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/7010662311472697569'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/10/summing-column-value-in-sql.html' title='Summing column value in SQL'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-1713176924364763485</id><published>2010-09-25T04:30:00.001-07:00</published><updated>2010-09-25T04:32:24.641-07:00</updated><title type='text'>Do you work with presentation</title><content type='html'>If you work with powerpoint presentation you must see this clip to get best out of it. &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.youtube.com/watch?v=lpvgfmEU2Ck&amp;amp;feature=player_embedded&quot;&gt;http://www.youtube.com/watch?v=lpvgfmEU2Ck&amp;amp;feature=player_embedded&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/1713176924364763485/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/09/do-you-work-with-presentation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/1713176924364763485'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/1713176924364763485'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/09/do-you-work-with-presentation.html' title='Do you work with presentation'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-673347386913891622</id><published>2010-08-14T08:46:00.000-07:00</published><updated>2010-08-14T08:49:32.832-07:00</updated><title type='text'>Macrodef in Ant Script</title><content type='html'>Very frequently we invoke the same task repeatedly with a  small variance. Mostly, we parameterize the variance, then  such tasks can be refactored and invoked with different argument  repeatedly, just like a Java method call that is invoked with different  arguments. Prior to Ant 1.6, the &lt;ant&gt; and &lt;antcall&gt; tasks  came in handy. For most part these two core tasks are similar, except  the &lt;ant&gt; task allows invoking targets in another build file  whereas &lt;antcall&gt; restricted the invoked targets to the local  file.&lt;/antcall&gt;&lt;/ant&gt;&lt;/antcall&gt;&lt;/ant&gt;&lt;br /&gt;
The point to consider is &lt;antcall&gt; re-parses the build file and re-runs the  targets, even though all that changes from one call to another is, in  most cases, just the parameter values. Since Ant 1.6 a smarter  alternative is available: the &lt;macrodef&gt; task. It offers all the  benefits of &lt;antcall&gt; without the overhead of reparsing. It offers  additional features such as ordered execution of nested tasks using the  &lt;sequential&gt; construct. Optional attributes can be supplied with  default values, and the caller may omit them.&amp;nbsp;  &lt;/sequential&gt;&lt;/antcall&gt;&lt;/macrodef&gt;&lt;/antcall&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;b&gt;Sample Code&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnmKtKQI2uM27y04nrCTouyp_p0dj-lWBKMOkTHZZThs4eoWCQpw18VdBuq5TV388_AFWhca7VStvu18_dvyYaEZssXgNbJKVUL8UmhuXVfxqsqQlsLzVsN4lYEJWE0EtvUjwEQR7yKRv0/s1600/macrodef.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;160&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnmKtKQI2uM27y04nrCTouyp_p0dj-lWBKMOkTHZZThs4eoWCQpw18VdBuq5TV388_AFWhca7VStvu18_dvyYaEZssXgNbJKVUL8UmhuXVfxqsqQlsLzVsN4lYEJWE0EtvUjwEQR7yKRv0/s400/macrodef.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
For further information&amp;nbsp; - &lt;a href=&quot;http://ant.apache.org/manual/Tasks/macrodef.html&quot;&gt;Ant - Macrodef&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/673347386913891622/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/08/macrodef-in-ant-script.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/673347386913891622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/673347386913891622'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/08/macrodef-in-ant-script.html' title='Macrodef in Ant Script'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnmKtKQI2uM27y04nrCTouyp_p0dj-lWBKMOkTHZZThs4eoWCQpw18VdBuq5TV388_AFWhca7VStvu18_dvyYaEZssXgNbJKVUL8UmhuXVfxqsqQlsLzVsN4lYEJWE0EtvUjwEQR7yKRv0/s72-c/macrodef.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-5264912883547101769</id><published>2010-08-01T06:47:00.004-07:00</published><updated>2010-08-01T06:47:51.242-07:00</updated><title type='text'>Clustering</title><content type='html'>J2EE application server vendors define a cluster as a group of machines working  together to transparently provide enterprise services (support for JNDI, EJB,  JSP, HttpSession and component failover, and so on). They leave the definition  purposely vague because each vendor implements clustering differently. At one  end of the spectrum rest vendors who put a dispatcher in front of a group of  independent machines, none of which has knowledge of the other machines in the  cluster. In this scheme, the dispatcher receives an initial request from a user  and replies with an HTTP redirect header to pin the client to a particular  member server of the cluster. At the other end of the spectrum reside vendors  who implement a federation of tightly integrated machines, with each machine  totally aware of the other machines around it along with the objects on those  machines.&lt;br /&gt;
&lt;br /&gt;
Purpose - &lt;br /&gt;
1. Reducing downtime - Another machine in cluster  transperently takeover in case of failure of a particular machine.&lt;br /&gt;
2.  Scalibility - More server can be added to handle the increased users.&lt;br /&gt;
3.  Spreading load - Different machines in the cluster will be responsible for the  indivudual module of the application hence decreasing the load on individual  machine.&lt;br /&gt;
&lt;br /&gt;
A cluster is a group of application servers that transparently  run your J2EE application as if it were a single entity. To scale, you should  include additional machines within the cluster. To minimize downtime, make sure  every component of the cluster is redundant.&lt;br /&gt;
&lt;br /&gt;
For More Information - &lt;a href=&quot;http://www.javaworld.com/jw-02-2001/jw-0223-extremescale.html&quot;&gt;Java World  - Clustering&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/5264912883547101769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/08/clustering.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/5264912883547101769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/5264912883547101769'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/08/clustering.html' title='Clustering'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-1451911822577019321</id><published>2010-08-01T06:47:00.002-07:00</published><updated>2010-08-01T06:47:31.993-07:00</updated><title type='text'>Runtime exception in JSP</title><content type='html'>How does JSP handle run-time exceptions?&lt;br /&gt;
&lt;br /&gt;
Runtime exceptions are easy to  handle in a JSP application, because they are stored one at a time in the  implicit object named exception. You can use the exception object in a special  type of JSP page called an error page, where you display the exception&#39;s name  and class, its stack trace, and an informative message for your user. &lt;br /&gt;
&lt;br /&gt;
We  can use the errorPage attribute of the page directive to have uncaught run-time  exceptions automatically forwarded to an error processing page. For example:  &lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;&amp;lt;\%@ page errorPage=&quot;error.jsp&quot; %&amp;gt;&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
redirects the  browser to the JSP page error.jsp if an uncaught exception is encountered during  request processing.&lt;br /&gt;
&lt;br /&gt;
Within error.jsp, if you indicate that it is an  error-processing page, via the directive:&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;&amp;lt;\%@ page  isErrorPage=&quot;true&quot; %&amp;gt;&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
the Throwable object describing the  exception may be accessed within the error page via the exception implicit  object.&lt;br /&gt;
&lt;br /&gt;
Note: You must always use a relative URL as the value for the  errorPage attribute.</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/1451911822577019321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/08/runtime-exception-in-jsp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/1451911822577019321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/1451911822577019321'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/08/runtime-exception-in-jsp.html' title='Runtime exception in JSP'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-242979078475109351</id><published>2010-08-01T06:47:00.000-07:00</published><updated>2010-08-01T06:47:11.197-07:00</updated><title type='text'>Simply Singleton</title><content type='html'>Singleton Design Pattern is the among the most widely used design patterns in IT  world. It addresses the problem of creating exactly one instance of a class  which can be globally accessible. This instance or object of class is  singleton.&lt;br /&gt;
&lt;br /&gt;
Singletons maintain a static reference to the sole singleton  instance and return a reference to that instance from a static instance()  method. &lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;public class MySingleton {&lt;br /&gt;
private static MySingleton  instance = null;&lt;br /&gt;
protected MySingleton() {&lt;br /&gt;
// Exists only to defeat  instantiation.&lt;br /&gt;
}&lt;br /&gt;
public static MySingleton getInstance() {&lt;br /&gt;
if(instance  == null) {&lt;br /&gt;
instance = new MySingleton();&lt;br /&gt;
}&lt;br /&gt;
return  instance;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class SingletonInstantiator { &lt;br /&gt;
public  SingletonInstantiator() { &lt;br /&gt;
ClassicSingleton instance =  ClassicSingleton.getInstance();&lt;br /&gt;
ClassicSingleton anotherInstance =&lt;br /&gt;
new  ClassicSingleton();&lt;br /&gt;
... &lt;br /&gt;
} &lt;br /&gt;
}&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
This technique of  implementing Singleton is known as lazy loading as the object is instantiated  when getInstance() method is called for the first time.&lt;br /&gt;
&lt;br /&gt;
Why constructor  is protected?? - First thing first. Protected constructor can be called by  subclasses or by other classes in the same package. So keeping the MySingleton  and SingletonInstantiator in the same package allows the former class to create  instance of singleton class. So what should be done? First, make the constructor  of MySingleton private, but then this class can not be subclassed. Second,  declare MySingleton as final. Third, put your singleton class in explicit  package.&lt;br /&gt;
&lt;br /&gt;
A third interesting point about ClassicSingleton: it&#39;s possible  to have multiple singleton instances if classes loaded by different classloaders  access a singleton. That scenario is not so far-fetched; for example, some  servlet containers use distinct classloaders for each servlet, so if two  servlets access a singleton, they will each have their own instance.  &lt;br /&gt;
&lt;br /&gt;
Fourth, if ClassicSingleton implements the java.io.Serializable  interface, the class&#39;s instances can be serialized and deserialized. However, if  you serialize a singleton object and subsequently deserialize that object more  than once, you will have multiple singleton instances. &lt;br /&gt;
&lt;br /&gt;
Finally, and  perhaps most important, Example 1&#39;s ClassicSingleton class is not thread-safe.  If two threads—we&#39;ll call them Thread 1 and Thread 2—call  ClassicSingleton.getInstance() at the same time, two ClassicSingleton instances  can be created if Thread 1 is preempted just after it enters the if block and  control is subsequently given to Thread 2. The solution to this is to  synchronize the getInstance() method in our MySingleton class or just the block  where we are creating the instance to improve performance by locking the object  for short time.&lt;br /&gt;
&lt;br /&gt;
For more information - &lt;br /&gt;
&lt;a href=&quot;http://www.javaworld.com/javaworld/jw-04-2003/jw-0425-designpatterns.html&quot;&gt;Java  World - Simply Singleton&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/242979078475109351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/08/simply-singleton.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/242979078475109351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/242979078475109351'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/08/simply-singleton.html' title='Simply Singleton'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-2773736355742726908</id><published>2010-08-01T06:46:00.001-07:00</published><updated>2010-08-01T06:46:35.963-07:00</updated><title type='text'>How to get Remote Machine Name</title><content type='html'>In order to get machine name or the computer name of the remote system, the  system which is send some http request to your server, you just need to get IP  from the request and using that IP and the InetAddress class of java.net  package, we can very well get the name of that machine. Here is the  code.&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;public void doPost(HttpServletRequest req, HttpServletResponse  res) throws IOException, ServletException{ &lt;br /&gt;
&lt;br /&gt;
byte ipAddr[] =  {0,0,0,0};&lt;br /&gt;
String ipAddress = req.getRemoteAddr();&lt;br /&gt;
&lt;br /&gt;
if(ipAddress !=  null &amp;amp;&amp;amp; !ipAddress.equals(&quot;&quot;)){&lt;br /&gt;
StringTokenizer tokenize = new  StringTokenizer(ipAddress,&quot;.&quot;);&lt;br /&gt;
&lt;br /&gt;
int iLen =  tokenize.countTokens();&lt;br /&gt;
&lt;br /&gt;
for(int i = 0 ; i &amp;lt; iLen;i++){&lt;br /&gt;
int temp =  Integer.parseInt(tokenize.nextToken());&lt;br /&gt;
ipAddr[i] = (byte)temp;  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
InetAddress nIpAddress =  InetAddress.getByAddress(ipAddr);&lt;br /&gt;
&lt;br /&gt;
if(nIpAddress != null &amp;amp;&amp;amp;  nIpAddress.isReachable(5000) &amp;amp;&amp;amp;  nIpAddress.isSiteLocalAddress()){&lt;br /&gt;
&lt;br /&gt;
System.out.println(&quot;Servlet -  &quot;+InetAddress.getByAddress(ipAddr).getHostName());&lt;br /&gt;
&lt;br /&gt;
req.setAttribute(&quot;IP&quot;,  InetAddress.getByAddress(ipAddr).getHostName());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;/em&gt;</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/2773736355742726908/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/08/how-to-get-remote-machine-name.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/2773736355742726908'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/2773736355742726908'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/08/how-to-get-remote-machine-name.html' title='How to get Remote Machine Name'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-3013792804696273390</id><published>2010-08-01T06:45:00.003-07:00</published><updated>2010-08-01T06:45:40.381-07:00</updated><title type='text'>Java 1.5 - Nothing un-official about it!!</title><content type='html'>&lt;strong&gt;Features in Java 1.5&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;1. For/Each  loop&lt;/strong&gt;&lt;br /&gt;
Instead of looping with a numeric index, set a local variable  to each item of a collection or array in order.&lt;br /&gt;
&lt;br /&gt;
public void  goThis(String[] strArray){&lt;br /&gt;
for(String  obj:strArray){&lt;br /&gt;
System.out.println(obj);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;2. Scanner  Class&lt;/strong&gt; - Scanner class is easily used to read the input from  console.&lt;br /&gt;
&lt;br /&gt;
Scanner inputScanner = new Scanner(System.in);&lt;br /&gt;
String s =  inputScanner.nextLine();&lt;br /&gt;
int i = inputScanner.nextInt();&lt;br /&gt;
double d =  inputScanner.nextDouble();&lt;br /&gt;
&lt;br /&gt;
But you can also attach a Scanner to a File, a  Socket, a Process, and more&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;3. Autoboxing&lt;/strong&gt; - To insert  java primitive into tables, list or anything expecting Object can be done using  Java wrappers.&lt;br /&gt;
&lt;br /&gt;
Although its a useful feature of java5 still its a  performance hit because - &lt;br /&gt;
1. Every insert converts to wrapper type.&lt;br /&gt;
2.  Every retrieval converts to primitive type&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;List&lt;integer&gt; arrayList =  new ArrayList&lt;integer&gt;();&lt;br /&gt;
int i = 12;&lt;br /&gt;
arrayList.add(i);&lt;br /&gt;
int num =  arrayList.get(0);&lt;br /&gt;
arrayList.add(num+1);&lt;/integer&gt;&lt;/integer&gt;&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;4.  Varargs&lt;/strong&gt; - A way to pass any number of a particular type of argument to  the method. It becomes an array of that type. It should be te last in the list  of arguments like&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;public static String method (String name, int ...  numbers);&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
Sample code - &lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;public class MathUtils  {&lt;br /&gt;
&lt;br /&gt;
public static int min(int ... numbers) {&lt;br /&gt;
&lt;br /&gt;
int minimum =  Integer.MAX_VALUE;&lt;br /&gt;
&lt;br /&gt;
for(int number: numbers) {&lt;br /&gt;
if (number &amp;lt; minimum)  {&lt;br /&gt;
minimum =  number;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return(minimum);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public static void  main(String[] args) {&lt;br /&gt;
&lt;br /&gt;
System.out.printf(&quot;Min of 2 nums:  %d.%n&quot;,min(2,1));&lt;br /&gt;
System.out.printf(&quot;Min of 7 nums:  %d.%n&quot;,min(2,4,6,8,1,2,3));&lt;br /&gt;
&lt;br /&gt;
}&lt;/em&gt;</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/3013792804696273390/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/08/java-15-nothing-un-official-about-it.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/3013792804696273390'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/3013792804696273390'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/08/java-15-nothing-un-official-about-it.html' title='Java 1.5 - Nothing un-official about it!!'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-6812674788566018468</id><published>2010-08-01T06:45:00.001-07:00</published><updated>2010-08-01T06:45:16.884-07:00</updated><title type='text'>Collect all about Garbage Collection</title><content type='html'>&amp;gt;&amp;gt;&amp;gt; The purpose of garbage collection is to identify and discard  objects that are no longer needed by a program so that their resources can be  reclaimed and reused.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; An unreachable object is subjected to  gc. Unreachable objects are those which can not be  referenced.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; Garbage collection is also called automatic  memory management as JVM automatically removes the unused variables/objects  (value is null) from the memory.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; Every class inherits  finalize() method from java.lang.Object, the finalize() method is called by  garbage collector when it determines no more references to the object exists.  &lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; In Java, it is good idea to explicitly assign null into a  variable when no more in use. &lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; In Java on calling  System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there  is no guarantee when all the objects will garbage collected.  &lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; Garbage collection is an automatic process and can&#39;t be  forced.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; gc thread is a dameon thread.</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/6812674788566018468/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/08/collect-all-about-garbage-collection.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/6812674788566018468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/6812674788566018468'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/08/collect-all-about-garbage-collection.html' title='Collect all about Garbage Collection'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6182869092006240514.post-6795977289367484830</id><published>2010-08-01T06:44:00.005-07:00</published><updated>2010-08-01T06:44:58.371-07:00</updated><title type='text'>Except exceptions!!</title><content type='html'>Exception in layman term is abnormal behaviour of your program. A bunch of  things can lead to exceptions, including hardware failures, resource exhaustion,  and good old bugs. When an exceptional event occurs in Java, an exception is  said to be thrown. The code that’s responsible for doing something about the  exception is called an exception handler, and it catches the thrown  exception.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; Order of catch block matters.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;  The finally clause is used to provide the capability to execute code no matter  whether or not an exception is thrown or caught.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; A checked  exception is some subclass of Exception (or Exception itself) excluding class  RuntimeException and its subclasses, which are forced by compiler to be checked.  Example: IOException.&lt;br /&gt;
Unchecked exceptions are RuntimeException and any of  its subclasses. Class Error and its subclasses also are unchecked. The compiler  doesn&#39;t force client programmers either to catch the exception or declare it in  a throws clause. In fact, client programmers may not even know that the  exception could be thrown. Example: ArrayIndexOutOfBoundsException. Errors are  often irrecoverable conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; Throwable is the base class  of Error and Exception.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; The throw keyword denotes a  statement that causes an exception to be initiated. The throws keyword is a  modifier of a method that denotes that an exception may be thrown by the  method.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; Error&#39;s are generally system&#39;s error and Excepion  are programmer&#39;s error.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; Finally block get executed whether  exception is thrown or not. Even if there is return statement in try block,  finally block get executed after the return statement.&lt;br /&gt;
&lt;br /&gt;
Defensive Coding  for NPE - &lt;br /&gt;
1. If name is null&lt;br /&gt;
don&#39;t do - if(name.equals(&quot;Peter&quot;)) -  chances to get NPE&lt;br /&gt;
do - if(&quot;Peter&quot;.equals(name))&lt;br /&gt;
2. Always return empty  collection instead of null like&lt;br /&gt;
return Collections.EMPTY_LIST;&lt;br /&gt;
3. Always  check for null before carrying out operation on the object and define alternate  course of action.</content><link rel='replies' type='application/atom+xml' href='http://click2test.blogspot.com/feeds/6795977289367484830/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://click2test.blogspot.com/2010/08/except-exceptions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/6795977289367484830'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6182869092006240514/posts/default/6795977289367484830'/><link rel='alternate' type='text/html' href='http://click2test.blogspot.com/2010/08/except-exceptions.html' title='Except exceptions!!'/><author><name>Arun Jain</name><uri>http://www.blogger.com/profile/14228609651188734494</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>