<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;A08CRHwyeip7ImA9WhRUGUw.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529</id><updated>2012-01-30T02:37:45.292-08:00</updated><category term="Bitcoin" /><category term="video" /><category term="foto" /><category term="Java" /><category term="Eclipse" /><category term="Mac" /><category term="random" /><title>Obscured Clarity</title><subtitle type="html">a cache for curiosity</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://obscuredclarity.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>167</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/ObscuredClarity" /><feedburner:info uri="obscuredclarity" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>ObscuredClarity</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;A08CRHwycCp7ImA9WhRUGUw.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-861037157415924889</id><published>2012-01-30T02:37:00.000-08:00</published><updated>2012-01-30T02:37:45.298-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-30T02:37:45.298-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Java Web App in Tomcat Dropping Sessions</title><content type="html">Want to integrate charts into your webapp? Check out &lt;a href="http://obscuredclarity.blogspot.com/2011/08/java-web-apps-integrating-charts-into.html"&gt;XChart&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Here's another nano-blog that will hopefully help someone solve an problem that I was dealing with today:&lt;br /&gt;
&lt;h1&gt;Problem&lt;/h1&gt;&lt;p&gt;I upgraded Tomcat from 7.0.22 to 7.0.25 and my web application starting closing or dropping the session that was being created during a user login operation. I also noticed in my log files, which tracks sessions being created and closed that tons of sessions were being created at once.&lt;/p&gt;&lt;h1&gt;Solution&lt;/h1&gt;&lt;p&gt;I'm not sure why this helps or why the problem suddenly appeared in a new release of Tomcat, but what I ended up doing to solve the problem was to add &lt;%@ page session="false" %&gt; to all my JSP files. Apparently for each JSP file, a session is otherwise created. In my web app I have several JSPs nested inside of other JSPs, which was probably causing all the sessions to be created. Why that was never an issue before, I'm not quite sure.&lt;/p&gt;I hope that helps someone!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-861037157415924889?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/861037157415924889/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=861037157415924889" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/861037157415924889?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/861037157415924889?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/qjQ7f2_Ycnk/java-web-app-in-tomcat-dropping.html" title="Java Web App in Tomcat Dropping Sessions" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2012/01/java-web-app-in-tomcat-dropping.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C04HQnY7eCp7ImA9WhRUFE4.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-492386660058430223</id><published>2012-01-24T11:05:00.001-08:00</published><updated>2012-01-24T11:05:33.800-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-24T11:05:33.800-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="foto" /><title>High Speed video of Canon DSLR Shutter</title><content type="html">&lt;iframe width="560" height="315" src="http://www.youtube.com/embed/6x_YXj0vWVM" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-492386660058430223?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/492386660058430223/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=492386660058430223" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/492386660058430223?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/492386660058430223?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/yTpA4xZ9y7w/high-speed-video-of-canon-dslr-shutter.html" title="High Speed video of Canon DSLR Shutter" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/6x_YXj0vWVM/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2012/01/high-speed-video-of-canon-dslr-shutter.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0MFR3Y9eyp7ImA9WhRUEkQ.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-6583275132357060832</id><published>2012-01-22T22:15:00.000-08:00</published><updated>2012-01-22T22:16:56.863-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T22:16:56.863-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Bitcoin" /><title>My First Experience Buying Something with Bitcoin</title><content type="html">I thought I would share a positive experience I recently had buying something with Bitcoin on &lt;a href="http://bitmit.net/"&gt;Bitmit.net&lt;/a&gt; as a success story not only for Bitcoin but also as a test of the trustwothiness of Bitmit and their Escrow service. I'm not affiliated with them at all...&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-aHAM1KxmLYg/Txz4q-ihk8I/AAAAAAAACUo/B30lkuJGBLg/s1600/IMG_6986.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="266" width="400" src="http://3.bp.blogspot.com/-aHAM1KxmLYg/Txz4q-ihk8I/AAAAAAAACUo/B30lkuJGBLg/s400/IMG_6986.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span class="fullpost"&gt;&lt;br /&gt;
&lt;h1&gt;First the Bad News&lt;/h1&gt;I was the highest bidder on this &lt;a href="https://bitmit.net/trade/i/187-apple-macbook-13-zoll-2-4ghz-500gb-hd-4gb-ram/description"&gt;Macbook&lt;/a&gt; @ EUR 500.05. Then some strange stuff happened as copied directly from my email to bitmit:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-style:italic;"&gt;Today, after I placed my bid in EUR, I was shown that my winning bid was 500.05 BTC or 2665.67 EUR (Picture 1)! Yikes! But then I saw my bid in the bidding history below to be 500.05 EUR, which is makes sense.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-mQR50UyE8jI/Txz5uYrGnqI/AAAAAAAACU0/ZNN5mir5KPE/s1600/Picture%2B1.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="218" width="400" src="http://2.bp.blogspot.com/-mQR50UyE8jI/Txz5uYrGnqI/AAAAAAAACU0/ZNN5mir5KPE/s400/Picture%2B1.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style="font-style:italic;"&gt;Then, I refreshed the page, and saw that my bid was gone from the bidding history, that berlina won the auction at 481.05 EUR, and that I was out bid, which makes no sense (Picture 6).&lt;br /&gt;
Then maybe a half hour later, I was again the high bidder, but at a price of 552.27 EUR. The page also still said I was outbid.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-ORCqIk9ZcLg/Txz5zzdrK6I/AAAAAAAACVA/SIbBVgafrEs/s1600/Picture%2B6.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="214" width="400" src="http://1.bp.blogspot.com/-ORCqIk9ZcLg/Txz5zzdrK6I/AAAAAAAACVA/SIbBVgafrEs/s400/Picture%2B6.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style="font-style:italic;"&gt;I'm concerned about all the strange things I've seen: the 500.05/2665.67 BTC/EUR winning bid, then berlina having the winning bid after the fact, and then finally having the winning bid at 552.27 EUR (Picture 12).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-KN8RT66xGbA/Txz56JvntRI/AAAAAAAACVM/vwGDYwQ5y_A/s1600/Picture%2B12.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="215" width="400" src="http://2.bp.blogspot.com/-KN8RT66xGbA/Txz56JvntRI/AAAAAAAACVM/vwGDYwQ5y_A/s400/Picture%2B12.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h1&gt;Now the Good News&lt;/h1&gt;The response I received was professional and fair. They said they noticed the problems as well and were making some manual adjustments to get everything in order. They affirmed I was indeed the highest bidder and they manually set the BTC price as EUR 500.05 divided by the average price of the previous 24 hours on mtgox, which came out to BTC 92.09. They also said I could abort the whole thing if I wanted given the situation. I believe they fixed the bugs.&lt;br /&gt;
Jumping forward, I ended up going for it and am now typing this on my new MacBook! Although the website was very buggy, the entire system worked, and I was happy with the escrow service they provide which you can watch for updates in your account:&lt;br /&gt;
&lt;br /&gt;
✓ Delivery details submitted&lt;br /&gt;
✓ Payment received (92.09 Bitcoin received)&lt;br /&gt;
✓ Item shipped (2012-01-18, 07:01)&lt;br /&gt;
✓ Item received (2012-01-18, 14:10)&lt;br /&gt;
✓ Money released&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-coOfLIS3-Do/Txz6tYdO1eI/AAAAAAAACVY/99sP6VnNsqg/s1600/Screen%2Bshot%2B2012-01-19%2Bat%2B11.40.22%2BAM.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="129" width="400" src="http://2.bp.blogspot.com/-coOfLIS3-Do/Txz6tYdO1eI/AAAAAAAACVY/99sP6VnNsqg/s400/Screen%2Bshot%2B2012-01-19%2Bat%2B11.40.22%2BAM.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
I posted this in hopes that other people will be more confident in buying and selling goods with Bitcoin and to record my experience with Bitmit for the benefit of others.&lt;br /&gt;
Now I'm looking for a MagSafe power supply and a micro-DVI to DVI adapter for my MacBook. Anyone have one they want to sell to me for Bitcoin?&lt;br /&gt;
Here is another Bitcoin auction site that I have no experience with yet at bitbid.net.&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-6583275132357060832?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/6583275132357060832/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=6583275132357060832" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/6583275132357060832?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/6583275132357060832?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/sv2J0QbXbPI/my-first-experience-buying-something.html" title="My First Experience Buying Something with Bitcoin" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-aHAM1KxmLYg/Txz4q-ihk8I/AAAAAAAACUo/B30lkuJGBLg/s72-c/IMG_6986.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2012/01/my-first-experience-buying-something.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0AFSX86fSp7ImA9WhRUEUk.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-5252028635687735256</id><published>2012-01-10T04:23:00.000-08:00</published><updated>2012-01-21T03:35:18.115-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-21T03:35:18.115-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="video" /><title>Plants, Fibonacci, Phi, and 137.5 Degrees</title><content type="html">&lt;iframe width="420" height="315" src="http://www.youtube.com/embed/ahXIMUkSXX0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;iframe width="480" height="360" src="http://www.youtube.com/embed/lOIP_Z_-0Hs" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;iframe width="420" height="315" src="http://www.youtube.com/embed/14-NdQwKz9w" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-5252028635687735256?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/5252028635687735256/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=5252028635687735256" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/5252028635687735256?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/5252028635687735256?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/FsxWG7d5wiI/plants-fibonacci-phi-and-1375-degrees.html" title="Plants, Fibonacci, Phi, and 137.5 Degrees" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/ahXIMUkSXX0/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2012/01/plants-fibonacci-phi-and-1375-degrees.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMGRnY5fip7ImA9WhRWF00.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-1115053283536158442</id><published>2012-01-04T11:46:00.000-08:00</published><updated>2012-01-04T11:47:07.826-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-04T11:47:07.826-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Mac" /><title>Check MD5 Hash on Mac OS X</title><content type="html">The following command can be used to calculate the &lt;a href="http://en.wikipedia.org/wiki/Md5sum"&gt;md5sum&lt;/a&gt; of a file on a Mac running OSX, functioning the same as the md5sum command in Linux...&lt;br /&gt;
&lt;br /&gt;
&lt;div class="unix"&gt;$ md5 -r /path/to/file/filename.ext &lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-1115053283536158442?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/1115053283536158442/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=1115053283536158442" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/1115053283536158442?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/1115053283536158442?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/BylLYoa3TeQ/check-md5-hash-on-mac-os-x.html" title="Check MD5 Hash on Mac OS X" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2012/01/check-md5-hash-on-mac-os-x.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QBQXs6cSp7ImA9WhRXGE8.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-764352238635141353</id><published>2011-12-25T08:08:00.000-08:00</published><updated>2011-12-25T08:09:10.519-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-25T08:09:10.519-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Serialize an Object to a JSON String in Java Using Gson</title><content type="html">To serialize a specified object or bean into its equivalent Json representation in Java we can use &lt;a href="http://code.google.com/p/google-gson/"&gt;Google's GSON library&lt;/a&gt;. First create a serializable object and set its fields to some values. Next new up a com.google.gson.Gson object. Finally call the Gson objects's toJson() method passing it your serializable object.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="fullpost"&gt;&lt;br /&gt;
&lt;pre name="code" class="java"&gt;import com.google.gson.Gson;

// The following example code demonstrates how to serialize a Bean
// object to a JSON String using the GSON library from Google.

public class Bean2JsonUsingGson {

    public static void main(String[] args) {

        SampleBean sampleBean = new SampleBean(3.14, "xyz", 42);
        Gson gson = new Gson();
        String json = gson.toJson(sampleBean);

        System.out.println(json);
    }

    static class SampleBean {

        private double value1;
        private String value2;
        private int value3;

        // Constructor
        SampleBean(double value1, String value2, int value3) {
            this.value1 = value1;
            this.value2 = value2;
            this.value3 = value3;
        }
    }
}

&lt;/pre&gt;Here is the output of the example program:&lt;br /&gt;
&lt;pre name="code" class="java"&gt;{"value1":3.14,"value2":"xyz","value3":42}
&lt;/pre&gt;&lt;br /&gt;
Piece of cake!!!&lt;br /&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-764352238635141353?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/764352238635141353/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=764352238635141353" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/764352238635141353?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/764352238635141353?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/cewTo2rhSps/serialize-object-to-json-string-in-java.html" title="Serialize an Object to a JSON String in Java Using Gson" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/12/serialize-object-to-json-string-in-java.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8HRng5fSp7ImA9WhRQFkQ.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-1365380796227926930</id><published>2011-12-12T05:56:00.000-08:00</published><updated>2011-12-12T06:07:17.625-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-12T06:07:17.625-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="random" /><title>ATP Synthase is a Rotating Motor That Creates ATP in our Cells</title><content type="html">&lt;img  src="http://i.imgur.com/jwD3x.gif" /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Photo Credit and a great description of how ATP Synthase works: &lt;a href="https://plus.google.com/u/0/114601143134471609087/posts"&gt;https://plus.google.com/u/0/114601143134471609087/posts&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-1365380796227926930?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/1365380796227926930/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=1365380796227926930" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/1365380796227926930?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/1365380796227926930?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/S5cHHuTuGNQ/atp-synthase-is-rotating-motor-that.html" title="ATP Synthase is a Rotating Motor That Creates ATP in our Cells" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/12/atp-synthase-is-rotating-motor-that.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEMHRns_eyp7ImA9WhRQFk4.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-1613547635741567160</id><published>2011-12-11T07:20:00.001-08:00</published><updated>2011-12-11T11:40:37.543-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-11T11:40:37.543-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="video" /><title>Why we have blind spots - and how to see the blood vessels inside your own eye</title><content type="html">&lt;iframe width="480" height="360" src="http://www.youtube.com/embed/L_W-IXqoxHA" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
And an image I found &lt;a href="http://www.strokeupdate.co.uk/2010/12/eye-blood-vessels-and-the-risk-of-stroke/"&gt;here&lt;/a&gt; of the retinal blood vessels:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-VNBX9OmZyHU/TuUHLthmo8I/AAAAAAAACMo/slWa9wjAPpw/s1600/retina15.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="268" width="400" src="http://4.bp.blogspot.com/-VNBX9OmZyHU/TuUHLthmo8I/AAAAAAAACMo/slWa9wjAPpw/s400/retina15.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-1613547635741567160?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/1613547635741567160/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=1613547635741567160" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/1613547635741567160?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/1613547635741567160?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/dTmEjunSGMk/why-we-have-blind-spots-and-how-to-see.html" title="Why we have blind spots - and how to see the blood vessels inside your own eye" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/L_W-IXqoxHA/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/12/why-we-have-blind-spots-and-how-to-see.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEUHR3k9fCp7ImA9WhRQE0s.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-7115116445123274918</id><published>2011-12-08T09:43:00.000-08:00</published><updated>2011-12-08T09:43:56.764-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-08T09:43:56.764-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="video" /><title>Some Excellent Sci-Fi Short Films by BLR</title><content type="html">&lt;iframe src="http://player.vimeo.com/video/33030265?title=0&amp;amp;byline=0&amp;amp;portrait=0" width="400" height="170" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt;&lt;p&gt;&lt;a href="http://vimeo.com/33030265"&gt;Keloid Trailer - A Short Film by BLR&lt;/a&gt; from &lt;a href="http://vimeo.com/biglazyrobot"&gt;BLR_VFX&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;&lt;br /&gt;
&lt;iframe src="http://player.vimeo.com/video/33025640?title=0&amp;amp;byline=0&amp;amp;portrait=0" width="400" height="225" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt;&lt;p&gt;&lt;a href="http://vimeo.com/33025640"&gt;The Gift&lt;/a&gt; from &lt;a href="http://vimeo.com/biglazyrobot"&gt;BLR_VFX&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-7115116445123274918?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/7115116445123274918/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=7115116445123274918" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/7115116445123274918?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/7115116445123274918?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/OeQLEeEdnAQ/some-excellent-sci-fi-short-films-by.html" title="Some Excellent Sci-Fi Short Films by BLR" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/12/some-excellent-sci-fi-short-films-by.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0IGQHs5eyp7ImA9WhRQEUs.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-2772340384638753157</id><published>2011-12-06T03:05:00.000-08:00</published><updated>2011-12-06T03:05:21.523-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-06T03:05:21.523-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Set Font Style in an Excel File Using Java and POI</title><content type="html">To create an Excel file and style a cell's font in Java we can use &lt;a href="http://poi.apache.org/"&gt;Apache's POI library&lt;/a&gt;. First a HSSFWorkbook object is created and a HSSFSheet object is added. A HSSFRow is added to the sheet, and a HSSFCell is added to the row. To sent the font style of a cell's content, a HSSFFont object is created, customized, and applied to a HSSFCellStyle object which in turn is applied to a cell in the spreadsheet. The following sample code was successfully tested with POI versions 3.6 and 3.7.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="fullpost"&gt;&lt;br /&gt;
&lt;pre name="code" class="java"&gt;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;

// The following example code demonstrates how to create an Excel  
// file using the org.apache.poi library and style the font in a cell.

public class StyleExcelFileFont {

    public static void main(String[] args) {

        HSSFWorkbook workbook = new HSSFWorkbook();

        HSSFSheet firstSheet = workbook.createSheet("Sheet 1");

        // Write a String in Cell 2B
        HSSFRow row1 = firstSheet.createRow(1);
        HSSFCell cell2B = row1.createCell(1);
        cell2B.setCellValue(new HSSFRichTextString("Sample String"));

        // Style Font in Cell 2B
        HSSFCellStyle cellStyle = workbook.createCellStyle();
        cellStyle = workbook.createCellStyle();
        HSSFFont hSSFFont = workbook.createFont();
        hSSFFont.setFontName(HSSFFont.FONT_ARIAL);
        hSSFFont.setFontHeightInPoints((short) 16);
        hSSFFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        hSSFFont.setColor(HSSFColor.GREEN.index);
        cellStyle.setFont(hSSFFont);
        cell2B.setCellStyle(cellStyle);

        FileOutputStream fileOutputStream = null;
        try {
            fileOutputStream = new FileOutputStream(new File("/Temp/Test5.xls"));
            workbook.write(fileOutputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fileOutputStream != null) {
                try {
                    fileOutputStream.flush();
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}


&lt;/pre&gt;Here is a screenshot of the generated Excel File:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-yp7oprrfWfQ/Tt31qbQPFTI/AAAAAAAACME/mxfOySC2Aa4/s1600/Picture%2B1.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="258" width="400" src="http://4.bp.blogspot.com/-yp7oprrfWfQ/Tt31qbQPFTI/AAAAAAAACME/mxfOySC2Aa4/s400/Picture%2B1.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Piece of cake!!!&lt;br /&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-2772340384638753157?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/2772340384638753157/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=2772340384638753157" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/2772340384638753157?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/2772340384638753157?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/k5yKYf-Jqxs/set-font-style-in-excel-file-using-java.html" title="Set Font Style in an Excel File Using Java and POI" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-yp7oprrfWfQ/Tt31qbQPFTI/AAAAAAAACME/mxfOySC2Aa4/s72-c/Picture%2B1.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/12/set-font-style-in-excel-file-using-java.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4DQHs_fyp7ImA9WhRQEEQ.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-4249524927369706127</id><published>2011-12-05T05:49:00.000-08:00</published><updated>2011-12-05T05:49:31.547-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-05T05:49:31.547-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Set Background Color and Add Border to a Cell in an Excel File Using Java and POI</title><content type="html">To create an Excel file and style a cell with a background color and a border in Java we can use &lt;a href="http://poi.apache.org/"&gt;Apache's POI library&lt;/a&gt;. First a HSSFWorkbook object is created and a HSSFSheet object is added. A HSSFRow is added to the sheet, and a HSSFCell is added to the row. To add a String to the cell, a HSSFRichTextString is used. To add a background color to the cell and add a border, a HSSFCellStyle object is applied to the cell. The following sample code was successfully tested with POI versions 3.6 and 3.7.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="fullpost"&gt;&lt;br /&gt;
&lt;pre name="code" class="java"&gt;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;

// The following example code demonstrates how to create an Excel  
// file using the org.apache.poi library and style the cell by setting
// its background color and adding a border.

public class StyleExcelFileCells {

    public static void main(String[] args) {

        HSSFWorkbook workbook = new HSSFWorkbook();

        HSSFSheet firstSheet = workbook.createSheet("Sheet 1");

        // Write a String in Cell 2B
        HSSFRow row1 = firstSheet.createRow(1);
        HSSFCell cell2B = row1.createCell(1);
        cell2B.setCellValue(new HSSFRichTextString("Sample String"));

        // Style Cell 2B
        HSSFCellStyle cellStyle = workbook.createCellStyle();
        cellStyle = workbook.createCellStyle();
        cellStyle.setFillForegroundColor(HSSFColor.YELLOW.index);
        cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
        cellStyle.setBorderTop((short) 1); // single line border
        cellStyle.setBorderBottom((short) 1); // single line border
        cell2B.setCellStyle(cellStyle);

        FileOutputStream fileOutputStream = null;
        try {
            fileOutputStream = new FileOutputStream(new File("/Temp/Test4.xls"));
            workbook.write(fileOutputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fileOutputStream != null) {
                try {
                    fileOutputStream.flush();
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

&lt;/pre&gt;Here is a screenshot of the generated Excel File:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-YNqirjogMNw/TtzKV6R0-PI/AAAAAAAACL4/2rksZ8aEAmg/s1600/Picture%2B4.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="278" width="400" src="http://2.bp.blogspot.com/-YNqirjogMNw/TtzKV6R0-PI/AAAAAAAACL4/2rksZ8aEAmg/s400/Picture%2B4.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Piece of cake!!!&lt;br /&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-4249524927369706127?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/4249524927369706127/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=4249524927369706127" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/4249524927369706127?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/4249524927369706127?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/nkumahzr3hw/set-background-color-and-add-border-to.html" title="Set Background Color and Add Border to a Cell in an Excel File Using Java and POI" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-YNqirjogMNw/TtzKV6R0-PI/AAAAAAAACL4/2rksZ8aEAmg/s72-c/Picture%2B4.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/12/set-background-color-and-add-border-to.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0YEQXk4cSp7ImA9WhRQEE8.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-4693612381300708528</id><published>2011-12-04T12:05:00.000-08:00</published><updated>2011-12-04T12:05:00.739-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-04T12:05:00.739-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Read Contents of an Excel File using Java and POI</title><content type="html">To get the content from an Excel file in Java we can use &lt;a href="http://poi.apache.org/"&gt;Apache's POI library&lt;/a&gt;. First a file is imported from disk passing a FileInputStream object to a org.apache.poi.hssf.usermodel.HSSFWorkbook object. In this example only the first sheet was parsed. To access the cell content of the entire sheet, each row is iterated followed by iterating over each cell in the row. For each cell, the content is simply read using the getStringCellValue() method from the HSSFCell object. The following sample code was successfully tested with POI versions 3.6 and 3.7.&lt;br /&gt;
&lt;br /&gt;
Here is a screenshot of the test file I used for this example:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-BVhdJWLFsLI/TtvQ9lVd1WI/AAAAAAAACLs/GyJUwolCwKk/s1600/Picture%2B3.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="273" width="400" src="http://1.bp.blogspot.com/-BVhdJWLFsLI/TtvQ9lVd1WI/AAAAAAAACLs/GyJUwolCwKk/s400/Picture%2B3.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class="fullpost"&gt;&lt;br /&gt;
&lt;pre name="code" class="java"&gt;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Iterator;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

// The following example code demonstrates how to parse the contents
// of all cells in the first sheet of an Excel spreadsheet file

public class ReadExcelFile {

    public static void main(String[] args) {

        FileInputStream fileInputStream = null;
        try {
            fileInputStream = new FileInputStream("/Temp/Test1.xls");

            HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream);

            HSSFSheet sheet = workbook.getSheetAt(0);

            Iterator rows = sheet.rowIterator();
            while (rows.hasNext()) {
                HSSFRow row = (HSSFRow) rows.next();

                Iterator cells = row.cellIterator();
                while (cells.hasNext()) {
                    HSSFCell cell = (HSSFCell) cells.next();

                    System.out.println(cell.getStringCellValue());
                }
            }

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fileInputStream != null) {
                try {
                    fileInputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

&lt;/pre&gt;Here is the output of the program:&lt;br /&gt;
&lt;pre name="code" class="java"&gt;Hello
There
&lt;/pre&gt;Piece of cake!!!&lt;br /&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-4693612381300708528?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/4693612381300708528/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=4693612381300708528" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/4693612381300708528?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/4693612381300708528?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/PvzqHM9go-Y/read-contents-of-excel-file-using-java.html" title="Read Contents of an Excel File using Java and POI" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-BVhdJWLFsLI/TtvQ9lVd1WI/AAAAAAAACLs/GyJUwolCwKk/s72-c/Picture%2B3.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/12/read-contents-of-excel-file-using-java.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4DRXk8eyp7ImA9WhRQEE0.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-4103628545166815967</id><published>2011-12-04T04:49:00.000-08:00</published><updated>2011-12-04T04:49:34.773-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-04T04:49:34.773-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="video" /><title>Crow Vending Machine - Crows Find Coins for Peanuts</title><content type="html">&lt;iframe width="480" height="360" src="http://www.youtube.com/embed/NhmZBMuZ6vE" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;iframe width="480" height="360" src="http://www.youtube.com/embed/EdvEBEGRWkM" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-4103628545166815967?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/4103628545166815967/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=4103628545166815967" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/4103628545166815967?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/4103628545166815967?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/dPVNjIOnt14/crow-vending-machine-crows-find-coins.html" title="Crow Vending Machine - Crows Find Coins for Peanuts" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/NhmZBMuZ6vE/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/12/crow-vending-machine-crows-find-coins.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEQMQX0yfSp7ImA9WhRQEE0.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-7230234278804936307</id><published>2011-12-02T04:28:00.000-08:00</published><updated>2011-12-04T04:39:40.395-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-04T04:39:40.395-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="video" /><title>Wooden 6-bit Binary Calculator</title><content type="html">&lt;iframe width="480" height="360" src="http://www.youtube.com/embed/GcDshWmhF4A" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-7230234278804936307?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/7230234278804936307/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=7230234278804936307" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/7230234278804936307?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/7230234278804936307?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/xWgN-2TwyvY/wooden-6-bit-binary-calculator.html" title="Wooden 6-bit Binary Calculator" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/GcDshWmhF4A/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/12/wooden-6-bit-binary-calculator.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0AFRHo-cSp7ImA9WhRQEE0.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-3211391790572367449</id><published>2011-11-28T04:23:00.000-08:00</published><updated>2011-12-04T04:28:35.459-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-04T04:28:35.459-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Create an Excel File using Java and POI</title><content type="html">To create an Excel file in Java we can use &lt;a href="http://poi.apache.org/"&gt;Apache's POI library&lt;/a&gt;. The example file created by the following example code demostrates how to add a String, a Date, a Boolean, and a Number to specified cells in the spreadsheet. First a HSSFWorkbook object is created and a HSSFSheet object is added. A HSSFRow is added to the sheet, and a HSSFCell is added to the row. To add a String to the cell, a HSSFRichTextString is used. To add a Date to the cell, a HSSFCellStyle is used in conjunction with a HSSFDataFormat object appied to a Date object. A Boolean value and a Number value are added directly to the cell. The following sample code was successfully tested with POI versions 3.6 and 3.7.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="fullpost"&gt;&lt;br /&gt;
&lt;pre name="code" class="java"&gt;import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

// The following example code demonstrates how to create an Excel  
// file using the org.apache.poi library. In the sample file,
// a String, Date, Boolean, and Number are added to individual cells
// in the spreadsheet.

public class CreateExcelFile {

    public static void main(String[] args) {

        HSSFWorkbook workbook = new HSSFWorkbook();

        HSSFSheet firstSheet = workbook.createSheet("Sheet 1");

        // Write a String in Cell 1A
        HSSFRow row1 = firstSheet.createRow(0);
        HSSFCell cell1A = row1.createCell(0);
        cell1A.setCellValue(new HSSFRichTextString("Sample String"));

        // Write a Date in Cell 2B
        HSSFRow row2 = firstSheet.createRow(1);
        HSSFCell cell2B = row2.createCell(1);
        cell2B.setCellValue(new Date());
        // Format the Date so it looks like a date
        HSSFCellStyle cellStyle = workbook.createCellStyle();
        cellStyle = workbook.createCellStyle();
        cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));
        cell2B.setCellStyle(cellStyle);

        // Write a Boolean in Cell 3C
        HSSFRow row3 = firstSheet.createRow(2);
        HSSFCell cell3C = row3.createCell(2);
        cell3C.setCellValue(true);

        // Write a Number in Cell 4D
        HSSFRow row4 = firstSheet.createRow(3);
        HSSFCell cell4D = row4.createCell(3);
        cell4D.setCellValue(3.14);

        FileOutputStream fileOutputStream = null;
        try {
            fileOutputStream = new FileOutputStream(new File("/Temp/Test3.xls"));
            workbook.write(fileOutputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fileOutputStream != null) {
                try {
                    fileOutputStream.flush();
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}


&lt;/pre&gt;Here is a screenshot of the generated Excel File:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-t1RblPXFIpY/TttmGyOoGAI/AAAAAAAACLU/_Bt47F0fOVc/s1600/Picture%2B1.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="128" width="400" src="http://1.bp.blogspot.com/-t1RblPXFIpY/TttmGyOoGAI/AAAAAAAACLU/_Bt47F0fOVc/s400/Picture%2B1.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Piece of cake!!!&lt;br /&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-3211391790572367449?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/3211391790572367449/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=3211391790572367449" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/3211391790572367449?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/3211391790572367449?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/kx6qSD-MAsU/create-excel-file-using-java-and-poi.html" title="Create an Excel File using Java and POI" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-t1RblPXFIpY/TttmGyOoGAI/AAAAAAAACLU/_Bt47F0fOVc/s72-c/Picture%2B1.png" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/12/create-excel-file-using-java-and-poi.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D08MR347fCp7ImA9WhRRE0U.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-5087698701585868124</id><published>2011-11-27T01:24:00.001-08:00</published><updated>2011-11-27T01:24:46.004-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-27T01:24:46.004-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="video" /><title>Mars Science Laboratory (Curiosity Rover) Mission Animation</title><content type="html">&lt;iframe width="640" height="360" src="http://www.youtube.com/embed/BudlaGh1A0o" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-5087698701585868124?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/5087698701585868124/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=5087698701585868124" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/5087698701585868124?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/5087698701585868124?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/W_ZqEfNoPKo/mars-science-laboratory-curiosity-rover.html" title="Mars Science Laboratory (Curiosity Rover) Mission Animation" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/BudlaGh1A0o/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/11/mars-science-laboratory-curiosity-rover.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEMEQnY5fyp7ImA9WhRQEE0.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-780100184751991723</id><published>2011-11-19T04:38:00.000-08:00</published><updated>2011-12-04T04:40:03.827-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-04T04:40:03.827-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Get Sheet Names from an Excel File Using Java and POI</title><content type="html">To get the sheet names from an Excel file in Java we can use &lt;a href="http://poi.apache.org/"&gt;Apache's POI library&lt;/a&gt;. First a file is imported from disk passing a FileInputStream object to a org.apache.poi.hssf.usermodel.HSSFWorkbook object. Looping over each sheet in the Excel spreadsheet, the sheet name is determined using the workbook.getSheetName() method. The following sample code was successfully tested with POI versions 3.6 and 3.7.&lt;br /&gt;
&lt;br /&gt;
Here is a screenshot of the test file I used for this example:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-qg6F_2tlsD8/Tttppr5s7AI/AAAAAAAACLg/lGLxcFuq8wQ/s1600/Picture%2B2.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="273" width="400" src="http://4.bp.blogspot.com/-qg6F_2tlsD8/Tttppr5s7AI/AAAAAAAACLg/lGLxcFuq8wQ/s400/Picture%2B2.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span class="fullpost"&gt;&lt;br /&gt;
&lt;pre name="code" class="java"&gt;import java.io.FileInputStream;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;

// The following example code demonstrates how to get the Sheet
// names in an Excel spreadsheet file

public class GetExcelSheetNames {

    public static void main(String[] args) {

        FileInputStream fileInputStream = null;
        try {
            fileInputStream = new FileInputStream("/Temp/Test1.xls");

            HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream);

            // for each sheet in the workbook
            for (int i = 0; i &lt; workbook.getNumberOfSheets(); i++) {

                System.out.println("Sheet name: " + workbook.getSheetName(i));
            }

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fileInputStream != null) {
                try {
                    fileInputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}


&lt;/pre&gt;
Here is the output of the program:
&lt;pre name="code" class="java"&gt;Sheet name: Sheet1
Sheet name: Sheet2
Sheet name: Sheet3
&lt;/pre&gt;Piece of cake!!!
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-780100184751991723?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/780100184751991723/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=780100184751991723" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/780100184751991723?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/780100184751991723?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/C8iPpztALZ8/get-sheet-names-from-excel-file-using.html" title="Get Sheet Names from an Excel File Using Java and POI" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-qg6F_2tlsD8/Tttppr5s7AI/AAAAAAAACLg/lGLxcFuq8wQ/s72-c/Picture%2B2.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/12/get-sheet-names-from-excel-file-using.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUANSH0zfyp7ImA9WhdaFkg.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-9117265943948563454</id><published>2011-10-26T11:28:00.001-07:00</published><updated>2011-10-26T11:29:59.387-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-26T11:29:59.387-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="video" /><title>SAWSTOP - Inventor Puts His Own Finger in the Table Saw</title><content type="html">&lt;iframe width="640" height="360" src="http://www.youtube.com/embed/E3mzhvMgrLE" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-9117265943948563454?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/9117265943948563454/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=9117265943948563454" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/9117265943948563454?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/9117265943948563454?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/FgCJJgzJGb0/sawstop-inventer-puts-his-own-finger-in.html" title="SAWSTOP - Inventor Puts His Own Finger in the Table Saw" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/E3mzhvMgrLE/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/10/sawstop-inventer-puts-his-own-finger-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMHSHY9eCp7ImA9WhdaFkg.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-7231390874246380267</id><published>2011-10-26T11:23:00.001-07:00</published><updated>2011-10-26T11:23:59.860-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-26T11:23:59.860-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="video" /><title>The Inner Life of a Cell [HQ]</title><content type="html">&lt;iframe width="480" height="360" src="http://www.youtube.com/embed/firxS8BEhTk" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-7231390874246380267?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/7231390874246380267/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=7231390874246380267" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/7231390874246380267?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/7231390874246380267?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/ohQQ2V9SLno/inner-life-of-cell-hq.html" title="The Inner Life of a Cell [HQ]" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/firxS8BEhTk/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/10/inner-life-of-cell-hq.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEIAQ34_fCp7ImA9WhdaFkg.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-5186441091635131918</id><published>2011-10-20T11:07:00.000-07:00</published><updated>2011-10-26T11:09:02.044-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-26T11:09:02.044-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Validate a URL in Java</title><content type="html">To validate a URL String in Java we can use the java.net.URL object. First a URL object is created, passing the URL String to its constructor. If the URL String is malformed or invalid, a MalformedURLException will be thrown indicating a malformed URL. Next the URL is converted to a URI using the toURI() method. If URL is not formatted strictly according to to RFC2396 and cannot be converted to a URI, a URISyntaxException will be thrown indicating a malformed URL. The following code demonstrates how to validate a URL String.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="fullpost"&gt;&lt;br /&gt;
&lt;pre name="code" class="java"&gt;package url;

import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;

//
// The following example code demonstrates how to
// validate that a given URL is valid or not.
//
public class CheckURLValidity {

    public static void main(String[] args) {

        String testURLString = "https://thermodynamiccomputing.com/main?&amp;t=20&amp;f=52";
        System.out.println(isValidURL(testURLString));

        testURLString = "http6://thermodynamiccomputing.com/";
        System.out.println(isValidURL(testURLString));

        testURLString = "http://thermodynamiccomputing.com/   dd";
        System.out.println(isValidURL(testURLString));

        testURLString = "http://&amp;lt;thermodynamiccomputing.com";
        System.out.println(isValidURL(testURLString));
    }

    private static boolean isValidURL(String pUrl) {

        URL u = null;
        try {
            u = new URL(pUrl);
        } catch (MalformedURLException e) {
            return false;
        }
        try {
            u.toURI();
        } catch (URISyntaxException e) {
            return false;
        }
        return true;
    }

}

&lt;/pre&gt;Here is the output of the example code:&lt;br /&gt;
&lt;pre name="code" class="java"&gt;true
false
false
false
&lt;/pre&gt;Piece of cake!!!&lt;br /&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-5186441091635131918?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/5186441091635131918/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=5186441091635131918" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/5186441091635131918?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/5186441091635131918?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/IngzGOnGM-c/validate-url-in-java.html" title="Validate a URL in Java" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/10/validate-url-in-java.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEIGRXYzfip7ImA9WhdaFkg.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-6457962653343006243</id><published>2011-10-16T08:20:00.000-07:00</published><updated>2011-10-26T11:08:44.886-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-26T11:08:44.886-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Get Domain Name from a URL String in Java</title><content type="html">To get the domain name or sub-domain name from a URL String in Java we can use the java.net.URL object. First a URL object is created, passing the URL String to its constructor. If the URL String is malformed or invalid, a MalformedURLException will be thrown. The getHost() method is then used to pull only the part of the URL containing the domain name. The following code demonstrates getting the domain name from a URL String.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="fullpost"&gt;&lt;br /&gt;
&lt;pre name="code" class="java"&gt;import java.net.MalformedURLException;
import java.net.URL;

//
// The following example code demonstrates how to
// get the domain name from a URL String
//
public class GetDomainNameFromURL {

    public static void main(String[] args) throws MalformedURLException {

        String testURLString = "https://thermodynamiccomputing.com/main?&amp;t=20&amp;f=52";
        URL lURL = new URL(testURLString);
        String hostName = lURL.getHost();
        System.out.println(hostName);

        testURLString = "http://www.thermodynamiccomputing.com/main?&amp;t=20&amp;f=52";
        lURL = new URL(testURLString);
        hostName = lURL.getHost();
        System.out.println(hostName);

        testURLString = "http://www.sub.thermodynamiccomputing.com/main?&amp;t=20&amp;f=52";
        lURL = new URL(testURLString);
        hostName = lURL.getHost();
        System.out.println(hostName);

    }
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is the output of the example code:&lt;br /&gt;
&lt;pre name="code" class="java"&gt;thermodynamiccomputing.com
www.thermodynamiccomputing.com
www.sub.thermodynamiccomputing.com
&lt;/pre&gt;Piece of cake!!!&lt;br /&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-6457962653343006243?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/6457962653343006243/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=6457962653343006243" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/6457962653343006243?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/6457962653343006243?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/1ACXsNUw_d8/get-domain-name-from-url-string-in-java.html" title="Get Domain Name from a URL String in Java" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/10/get-domain-name-from-url-string-in-java.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEIEQ3s8fip7ImA9WhdaFkg.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-2245273823897674845</id><published>2011-10-05T15:24:00.000-07:00</published><updated>2011-10-26T11:08:22.576-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-26T11:08:22.576-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="video" /><title>Spherical Flying Machine Developed by Japan Ministry Of Defense</title><content type="html">&lt;iframe width="640" height="360" src="http://www.youtube.com/embed/pF0uLnMoQZA" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-2245273823897674845?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/2245273823897674845/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=2245273823897674845" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/2245273823897674845?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/2245273823897674845?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/d4OwHcbMurE/spherical-flying-machine-developed-by.html" title="Spherical Flying Machine Developed by Japan Ministry Of Defense" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/pF0uLnMoQZA/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/10/spherical-flying-machine-developed-by.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUAESXs6eip7ImA9WhdXGEs.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-5834047250349660825</id><published>2011-09-01T00:54:00.001-07:00</published><updated>2011-09-01T00:55:08.512-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-01T00:55:08.512-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="video" /><title>A White Blood Cell Capturing a Bacterium</title><content type="html">&lt;iframe width="480" height="390" src="http://www.youtube.com/embed/JnlULOjUhSQ" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-5834047250349660825?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/5834047250349660825/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=5834047250349660825" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/5834047250349660825?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/5834047250349660825?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/dAUwK2BIx1k/white-blood-cell-capturing-bacteria.html" title="A White Blood Cell Capturing a Bacterium" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/JnlULOjUhSQ/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/09/white-blood-cell-capturing-bacteria.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0EBSHc-fSp7ImA9WhdRE0o.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-5778435501549527123</id><published>2011-08-03T05:30:00.000-07:00</published><updated>2011-08-03T05:47:39.955-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-03T05:47:39.955-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Java Web Apps - Integrating Charts into a Servlet</title><content type="html">&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-LuL1akDG5ZE/TjlB7OfmE1I/AAAAAAAACJ8/o7hlU6Fni80/s1600/Picture%2B2.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="140" width="200" src="http://2.bp.blogspot.com/-LuL1akDG5ZE/TjlB7OfmE1I/AAAAAAAACJ8/o7hlU6Fni80/s200/Picture%2B2.png" /&gt;&lt;/a&gt;&lt;/div&gt;Adding a chart to a Java web application is really easy to do - thanks to the open source Java charting API &lt;a href="http://xeiam.com/xchart.jsp"&gt;XChart&lt;/a&gt;. XChart's charting library lets you very easily make charts an integrate them into all your Java-based applications. In this blog post, I am going to demonstrate how to add charts to a Java web application. If you want to integrate XChart charts in your Java applications, download the JAR &lt;a href="http://xeiam.com/xchart.jsp"&gt;here&lt;/a&gt;. You can also see more XChart exmaples &lt;a href="http://xeiam.com/xchart_examplecode.jsp"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;The Basic Idea&lt;/h1&gt;The basic idea for adding XChart charts to a web app is as follows. First, you have a JSP or HTML page with a link on it that will request a new page with a chart. The new JSP or HTML page that is generated has an img tag in it with a reference to an in-memory chart stored in a HashMap in a Servlet that maps the reference and the chart. When the page reloads, the browser parses the img tag and subsequently requests the image from the Servlet. The Servlet then streams the chart to the browser and it is rendered on the page.&lt;br /&gt;
&lt;span class="fullpost"&gt;&lt;br /&gt;
&lt;h1&gt;An Example&lt;/h1&gt;If the basic idea explanation above did not make complete sense, the following example should make it clear.&lt;br /&gt;
&lt;br /&gt;
Step 1: ChartServlet. This Servlet does one of two things in the doGet() method, depending on the request. If it receives and 'action', it generates a chart. Here you could pass in different 'action' parameters to create different charts if you want. If it receives a 'chart_id', it pulls the chart from CHART_MAP and streams it out to the browser.&lt;br /&gt;
&lt;pre name="code" class="java"&gt;import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xeiam.xcharts.BitmapEncoder;
import com.xeiam.xcharts.Chart;
import com.xeiam.xcharts.QuickChart;

@javax.servlet.annotation.WebServlet(name = "ChartServlet", urlPatterns = { "/chart" })
public class ChartServlet extends HttpServlet {

    private static Map&amp;lt;String, Chart&amp;gt; CHART_MAP = new HashMap&amp;lt;String, Chart&amp;gt;();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        // generate the Chart
        String action = request.getParameter("action");
        if (action != null &amp;&amp; !action.equals("null")) {
            String chartId = generateRandomChart();
            request.setAttribute("chart_id", chartId);
            request.getRequestDispatcher("/chart.jsp").forward(request, response);
        }

        // Fetch the Chart
        String chartId = request.getParameter("chart_id");
        if (chartId != null &amp;&amp; !chartId.equals("null")) {

            Chart chart = CHART_MAP.get(chartId);
            if (chart != null) {
                response.setContentType("image/png");
                ServletOutputStream out = response.getOutputStream();
                try {
                    BitmapEncoder.streamPNG(out, chart);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                out.close();
                chart = null;
                CHART_MAP.remove(chartId);
            } else {
                System.err.println("CHART NOT FOUND!!!");
            }
        }
    }

    // generate the chart
    public static String generateRandomChart() {
        Chart chart = QuickChart.getChart("XChart Sample - Random Walk", "X", "Y", null, null, getRandomWalk(105));
        String uuid = UUID.randomUUID().toString();
        CHART_MAP.put(uuid, chart);
        return uuid;
    }

    // generate random walk data set
    private static double[] getRandomWalk(int numPoints) {
        double[] y = new double[numPoints];
        y[0] = 0;
        for (int i = 1; i &amp;lt; y.length; i++) {
            y[i] = y[i - 1] + Math.random() - .5;
        }
        return y;
    }
}
&lt;/pre&gt;&lt;br /&gt;
Step 2: Chart JSP. To request and display the Chart, the JSP contains two DIVs - one for a link to request the chart and one for a IMG tag to display the Chart image. I named this JSP chart.jsp.&lt;br /&gt;
&lt;br /&gt;
&lt;pre name="code" class="java"&gt;&amp;lt;!DOCTYPE&amp;nbsp;html&amp;nbsp;PUBLIC&amp;nbsp;"-//W3C//DTD&amp;nbsp;XHTML&amp;nbsp;1.0&amp;nbsp;Strict//EN"&amp;nbsp;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&amp;gt;
&amp;lt;html&amp;nbsp;xmlns="http://www.w3.org/1999/xhtml"&amp;nbsp;xml:lang="en"&amp;gt;
&amp;nbsp;&amp;lt;head&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;meta&amp;nbsp;http-equiv="content-type"&amp;nbsp;content="text/html;charset=utf-8"&amp;nbsp;/&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;%&amp;nbsp;String&amp;nbsp;chartId&amp;nbsp;=&amp;nbsp;(String)&amp;nbsp;request.getAttribute("chart_id");%&amp;gt;
&amp;nbsp;&amp;lt;/head&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;body&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;div&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;a&amp;nbsp;href="&amp;lt;%=request.getContextPath()%&amp;gt;/chart?action=whatever"&amp;gt;Generate&amp;nbsp;Chart&amp;lt;/a&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/div&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;%if(chartId&amp;nbsp;!=&amp;nbsp;null){&amp;nbsp;%&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;div&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;img&amp;nbsp;src="&amp;lt;%=request.getContextPath()%&amp;gt;/chart?chart_id=&amp;lt;%=chartId&amp;nbsp;%&amp;gt;"/&amp;gt;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/div&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;lt;%}&amp;nbsp;%&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
Step 3: Test it. Now deploy your webapp with the new Servlet and JSP and in your browser go to: http://localhost/YourWebAppContext/chart.jsp&lt;br /&gt;
&lt;br /&gt;
After clicking on 'Generate Chart' your chart will appear on the web page. Each time you click it, a new chart will show up.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-Zat66wS2tgE/Tjk9hrGsmNI/AAAAAAAACJ0/3vrcHqmYjBc/s1600/Picture%2B1.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="321" width="400" src="http://2.bp.blogspot.com/-Zat66wS2tgE/Tjk9hrGsmNI/AAAAAAAACJ0/3vrcHqmYjBc/s400/Picture%2B1.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Piece of Cake!!!&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-5778435501549527123?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/5778435501549527123/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=5778435501549527123" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/5778435501549527123?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/5778435501549527123?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/RPrAz2zM0Jk/java-web-apps-integrating-charts-into.html" title="Java Web Apps - Integrating Charts into a Servlet" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-LuL1akDG5ZE/TjlB7OfmE1I/AAAAAAAACJ8/o7hlU6Fni80/s72-c/Picture%2B2.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/08/java-web-apps-integrating-charts-into.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkMASHw_fCp7ImA9WhdREkU.&quot;"><id>tag:blogger.com,1999:blog-4650152229438238529.post-1852128535096461293</id><published>2011-08-02T05:34:00.000-07:00</published><updated>2011-08-02T05:34:09.244-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-02T05:34:09.244-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Using Yank as a MySQL Persistence Layer in Your Java Application</title><content type="html">&lt;a href="http://xeiam.com/yank.jsp"&gt;Yank&lt;/a&gt; is a lightweight JDBC persistence layer API for any type of Java application. Looking at the &lt;a href="http://xeiam.com/yank/javadoc/index.html"&gt;JavaDocs&lt;/a&gt;, we can see that it only has a grand total of 5 classes. I love APIs like this because I can dig into the JavaDocs and very quickly understand the design and structure, making it a snap to get up and running with working code. Yank makes it easy to interact with JDBC databases in a structured, organized, and clean-cut approach. If you don't use a persistence layer like this, you quickly find that your database querying code becomes an unmanageable mess.&lt;br /&gt;
&lt;span class="fullpost"&gt;&lt;br /&gt;
&lt;h1&gt;The Basic Idea&lt;/h1&gt;Each table in your database has a corresponding Java object. The object extends com.xeiam.yank.Bean and has private fields with names and data types that match the column names of your table. In other words, the Bean is a Java object that is a one-to-one mapping of a single row in your table.&lt;br /&gt;
&lt;br /&gt;
The next thing you need is a Data Access Object, or DAO, for the Bean. In this class, you create methods for interacting with the table. In each method, with only a few lines of code, you create the specific SQL query you want and use the com.xeiam.yank.DBProxy to handle the query for you.&lt;br /&gt;
&lt;br /&gt;
The advantage of this is that your code for interacting with the database is all wrapped up in just two very simple classes for each table in your database - a Bean and a DAO. And because the actual nitty-gritty details of handling database connections and results sets in handled for you in com.xeiam.yank.DBProxy, you don't have to worry about coding that yourself. It saves time and prevents errors. &lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;An Example&lt;/h1&gt;In order to make the relationship between a table, the Bean, and the DAO absolutely clear, I will walk through an example.&lt;br /&gt;
&lt;br /&gt;
Step 1: Create a table. I'll be using similar code to the Yank &lt;a href="http://xeiam.com/yank_examplecode.jsp"&gt;example code&lt;/a&gt; for this. In MySQL create a database called 'Yank' and add the following table called 'Books' to it:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="unix"&gt;CREATE TABLE `Books` (&lt;br /&gt;
  `TITLE` varchar(42) DEFAULT NULL,&lt;br /&gt;
  `AUTHOR` varchar(42) DEFAULT NULL,&lt;br /&gt;
  `PRICE` double DEFAULT NULL&lt;br /&gt;
) ENGINE=MyISAM DEFAULT CHARSET=utf8;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
Step 2: Create a Bean for the table. First, add the fields corresponding to the column names. The names MUST match, although case doesn't matter. Finally add getters and setters for all the fields. In Eclipse, these can be easily auto generated. &lt;br /&gt;
&lt;pre name="code" class="java"&gt;import com.xeiam.yank.Bean;

public class Book extends Bean {

    private String title;
    private String author;
    private double price;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "Book [title=" + title + ", author=" + author + ", price=" + price + "]";
    }

}
&lt;/pre&gt;&lt;br /&gt;
Step 3: Create a DAO class. I'll add two methods to it - one for inserting a Book and one for selecting all the books in the table.&lt;br /&gt;
&lt;pre name="code" class="java"&gt;import java.util.List;
import com.xeiam.yank.DBProxy;

public class BooksDAO {

    public static int insertBook(Book pBook) {

        Object[] params = new Object[] { pBook.getTitle(), pBook.getAuthor(), pBook.getPrice() };
        String SQL = "INSERT INTO BOOKS  (TITLE, AUTHOR, PRICE) VALUES (?, ?, ?)";
        return DBProxy.executeIUDSQL("local", SQL, params);
    }

    public static List&lt;Book&gt; selectAllBooks() {

        String SQL = "SELECT * FROM BOOKS";
        return (List&lt;Book&gt;) DBProxy.queryBeanListSQL("local", SQL, null, Book.class);
    }
}
&lt;/pre&gt;&lt;br /&gt;
Step 4: Use your new persistence layer in your code. For demonstration purposes, I'll create a simple class that calls the two methods in the DAO and prints out the results. In this class, first define the connection properties. The Yank API needs to know how to connect to your database: which JDBC driver, which table, which user, and the password, and how many Connections in the connection pool. For the last four properties, the word 'local' corresponds to the name of the connection pool. Notice in the DAO class that the DBProxy method calls are passed 'local' as the first parameter. This feature allows you to have multiple Connection pools in your application if you want.&lt;br /&gt;
&lt;pre name="code" class="java"&gt;import com.xeiam.yank.DBConnectionManager;

public class BooksExample {

    public static void main(String[] args) {

        Properties props = new Properties();
        props.setProperty("driverclassname", "com.mysql.jdbc.Driver");
        props.setProperty("local.url", "jdbc:mysql://localhost:3306/Yank");
        props.setProperty("local.user", "root");
        props.setProperty("local.password", "");
        props.setProperty("local.maxconn", "5");

        DBConnectionManager.INSTANCE.init(props, null);

        BooksDAO.createBooksTable();

        // Insert Book
        Book book = new Book();
        book.setTitle("Cryptonomicon");
        book.setAuthor("Neal Stephenson");
        book.setPrice(23.99);
        BooksDAO.insertBook(book);

        // Select All Books
        List&lt;Book&gt; allBooks = BooksDAO.selectAllBooks();
        for (Book book1 : allBooks) {
            System.out.println(book1.toString());
        }

        DBConnectionManager.INSTANCE.release();
    }
}
&lt;/pre&gt;Here's the output:&lt;br /&gt;
&lt;pre name="code" class="java"&gt;Book [title=Cryptonomicon, author=Neal Stephenson, price=23.99]
&lt;/pre&gt;Piece of Cake!!!&lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;Additional Information&lt;/h1&gt;As you can see, it is really easy to use Yank to push and pull data into and out of a database from your Java application. On the Yank &lt;a href="http://xeiam.com/yank_examplecode.jsp"&gt;example page&lt;/a&gt;, you can see a few more advanced capabilities as well. You can set up your database connection information in a properties file rather than directly in your Java code if you want. You can also keep all you SQL statements in a single properties file and access them using the DBProxy.*SQLKey() methods. In addition to the insert and select statements shown above, you can query in anyway you want: update, insert ignore, replace, batch query, etc. &lt;br /&gt;
&lt;br /&gt;
Yank has 3 dependencies, so in order to integrate Yank into your application you'll need not only the &lt;a href="http://xeiam.com/yank.jsp"&gt;Yank jar&lt;/a&gt; on your classpath, but also these:&lt;br /&gt;
&lt;a href="http://commons.apache.org/dbutils/index.html"&gt;Apache Commons DBUtils&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://www.slf4j.org/index.html"&gt;Simple Logging Facade for Java (SLF4J)&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://dev.mysql.com/downloads/connector/j/"&gt;MySQL Connector/J&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
And remember, this will work with any type of database that has a JDBC driver, such as PostgreSQL. You would just have to add the appropriate JDBC driver to your classpath, and modify the connection properties appropriately.&lt;br /&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4650152229438238529-1852128535096461293?l=obscuredclarity.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://obscuredclarity.blogspot.com/feeds/1852128535096461293/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4650152229438238529&amp;postID=1852128535096461293" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/1852128535096461293?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4650152229438238529/posts/default/1852128535096461293?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/ObscuredClarity/~3/jwXzKDjXoUs/using-yank-as-mysql-persistence-layer.html" title="Using Yank as a MySQL Persistence Layer in Your Java Application" /><author><name>Tim Molter</name><uri>http://www.blogger.com/profile/09117791052747688044</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_eIoDncf-Rgo/SPJImgjxWgI/AAAAAAAAAng/HzSmpiSedBI/S220/Tim3.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://obscuredclarity.blogspot.com/2011/08/using-yank-as-mysql-persistence-layer.html</feedburner:origLink></entry></feed>

