<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>SANDBOX.......</title>
	<atom:link href="http://veechand.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://veechand.wordpress.com</link>
	<description>Mirrored Blog</description>
	<lastBuildDate>Sat, 19 Dec 2009 16:07:43 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='veechand.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/a89d19d281918b8a7982da06664fc328?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>SANDBOX.......</title>
		<link>http://veechand.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://veechand.wordpress.com/osd.xml" title="SANDBOX&#8230;&#8230;." />
		<item>
		<title>Is a number Power of Two</title>
		<link>http://veechand.wordpress.com/2009/12/19/is-a-number-power-of-two/</link>
		<comments>http://veechand.wordpress.com/2009/12/19/is-a-number-power-of-two/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 15:59:55 +0000</pubDate>
		<dc:creator>Veerabahu</dc:creator>
				<category><![CDATA[techinal]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://veechand.wordpress.com/?p=657</guid>
		<description><![CDATA[finding is a number is power of 2 <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=657&subd=veechand&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Last week, I was reading through an article written by <a href="http://www.artima.com/wbc/interprog.html">Bill Venners</a> (don’t read this now). Though the purpose of the article is to highlight some of the key interviewing techniques, I was excited by <strong>Josh Bloch</strong> question, “Finding is a number power of 2”.</p>
<p>After finding few answers other than the one mentioned in the above article, I put the same question to some of my colleagues/friends. Most of them (99% of people, including me) immediately came up with the following answer “recursive (Number/2)==0, then power of 2” or continuous multiplication with 2 gives that number, as shown below</p>
<pre class="brush: java;">
int number = 8;
int tempNumber = 1;
while(tempNumber&lt;number){
    tempNumber*=2;
}
if(tempNumber==number){
   System.out.println(&quot;Power of&quot;);
else{
   System.out.println(&quot;Not a power of&quot;);
}
</pre>
<p>Yes, the above solve the problem in hand, but is this an efficient one? Will this work for large numbers or gives overflow issues? For sure I can’t see this solution as an efficient one. So I contacted my genius friend Sree. Not to the surprise, he came up with a more efficient solution. I and 99% of my friends have seen the problem in decimal but Sree has seen it in bits. Without further ado let us see the (one line) code</p>
<pre class="brush: java;">
 System.out.println(((number&amp;(number-1))==0)?&quot;Power of&quot;:&quot;Not a power of&quot;);
</pre>
<p>Hope you too accept it to be more efficient than mine  One other solution proposed by Josh Bloch in the article <a href="http://www.artima.com/wbc/interprog.html">http://www.artima.com/wbc/interprog.html</a>  (now read it) is </p>
<pre class="brush: java;">
System.out.println(((number&amp;(-number))==number)?&quot;Power of&quot;:&quot;Not a power of&quot;);
</pre>
<p>Which answer you came up with? Hey did you come up with some new one? Let us know the same.</p>
<p style="text-align:left;" class="getsocial"><a title="Add to Facebook" href="http://www.facebook.com/sharer.php?u=http://veechand.wordpress.com/2009/12/19/is-a-number-power-of-two" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4013.png" alt="Add to Facebook" /></a><a title="Add to Newsvine" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F12%2F19%2Fis-a-number-power-of-two&amp;h=Is%20a%20number%20Power%20of%20Two" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4023.png" alt="Add to Newsvine" /></a><a title="Add to Digg" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F12%2F19%2Fis-a-number-power-of-two&amp;title=Is%20a%20number%20Power%20of%20Two" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4033.png" alt="Add to Digg" /></a><a title="Add to Del.icio.us" href="http://del.icio.us/post?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F12%2F19%2Fis-a-number-power-of-two&amp;title=Is%20a%20number%20Power%20of%20Two" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4043.png" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F12%2F19%2Fis-a-number-power-of-two&amp;title=Is%20a%20number%20Power%20of%20Two" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4053.png" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" href="http://reddit.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F12%2F19%2Fis-a-number-power-of-two&amp;title=Is%20a%20number%20Power%20of%20Two" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4063.png" alt="Add to Reddit" /></a><a title="Add to Blinklist" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F12%2F19%2Fis-a-number-power-of-two&amp;Title=Is%20a%20number%20Power%20of%20Two" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4073.png" alt="Add to Blinklist" /></a><a title="Add to Twitter" href="http://twitter.com/home/?status=Is%20a%20number%20Power%20of%20Two+%40+http%3A%2F%2Fveechand.wordpress.com%2F2009%2F12%2F19%2Fis-a-number-power-of-two" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4083.png" alt="Add to Twitter" /></a><a title="Add to Technorati" href="http://www.technorati.com/faves?add=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F12%2F19%2Fis-a-number-power-of-two" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4093.png" alt="Add to Technorati" /></a><a title="Add to Furl" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F12%2F19%2Fis-a-number-power-of-two&amp;t=Is%20a%20number%20Power%20of%20Two" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4103.png" alt="Add to Furl" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veechand.wordpress.com/657/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veechand.wordpress.com/657/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veechand.wordpress.com/657/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veechand.wordpress.com/657/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veechand.wordpress.com/657/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veechand.wordpress.com/657/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veechand.wordpress.com/657/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veechand.wordpress.com/657/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veechand.wordpress.com/657/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veechand.wordpress.com/657/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=657&subd=veechand&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://veechand.wordpress.com/2009/12/19/is-a-number-power-of-two/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86b7deee7b6c29ee12158ba3455022e0?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">veeru</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4013.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4023.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4033.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4043.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4053.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4063.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4073.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4083.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4093.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4103.png" medium="image">
			<media:title type="html">Add to Furl</media:title>
		</media:content>
	</item>
		<item>
		<title>My experiences with AWS Chennai workshop</title>
		<link>http://veechand.wordpress.com/2009/11/11/my-experiences-with-amazon-web-services-workshop/</link>
		<comments>http://veechand.wordpress.com/2009/11/11/my-experiences-with-amazon-web-services-workshop/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 02:42:59 +0000</pubDate>
		<dc:creator>Veerabahu</dc:creator>
				<category><![CDATA[techinal]]></category>
		<category><![CDATA[aws awschennai]]></category>

		<guid isPermaLink="false">http://veechand.wordpress.com/?p=598</guid>
		<description><![CDATA[AWS EC2 S3<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=598&subd=veechand&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Today (10-Nov-2009) I have experienced many new things in my life. First to mention, being an inhabitant of Chennai only after five years of industry experience, today is my first day to visit <a href="http://www.tidelpark.com/">Tidel Park, Chennai</a>.  Also today I have my first time exposure to <a href="http://aws.amazon.com/">Amazon Web Services (AWS)</a>. It is a good <a href="http://awschennai.in/">workshop</a> that opened my eyes towards many new technical jargons. In this blog, I am trying to capture most of the items that are discussed today. Most of the things captured here are from my notes (or from top of my head), so they are going to be keywords rather than detailed explanations.<span id="more-598"></span></p>
<p>Amazon evangelist <a href="http://www.linkedin.com/in/jinman">Jinesh Varia</a>, after taking us through an introduction to Cloud Computing and its advantages talked about various cloud offerings from Amazon . In his words, Cloud Computing is one in which everything from storage, computing to network are accessed through APIs. APIs are exposed in REST, Query or SOAP/XML based.  For java developers, he has shown bunch of tools (sorry I couldn’t make note of everything) that comes handy, few to mention are <a href="http://code.google.com/p/typica/">typica</a>, <a href="http://aws.amazon.com/eclipse/">Eclipse Plug-in</a>. I am able to grab one of his slides from <a href="http://tinyurl.com/y86p624" target="_blank">slideshare</a>. Jinesh also spent good time in explaining about the key offerings from AWS like</p>
<ul>
<li><a href="http://aws.amazon.com/s3/">S3 &#8211; Distributed redundant storage</a></li>
<li><a href="http://aws.amazon.com/ebs/">EBS &#8211; Elastic Block storage</a></li>
<li><a href="http://aws.amazon.com/simpledb/">Amazon simple DB</a> &#8211; Light weight database, indexed and query able database. However it is not a relational database.</li>
<li><a href="http://aws.amazon.com/rds/">Amazon Relation Data Service</a> – It is a MySQL relation database service</li>
<li><a href="http://aws.amazon.com/sqs/">Amazon SQS</a> – I don’t have a proper definition of it, but from my understanding it is a Q that passes messages between applications/computers. It should be analogous to JMS queue</li>
<li><a href="http://aws.amazon.com/ec2/">EC2</a> – Virtual computation servers. It is where we create the instance that we need for processing. I see this as the heart of AWS.</li>
<li><a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1346">Elastic IP Address</a> – Static IP Addresses for virtual instances in clouds. <a href="http://www.8kmiles.com/">8kMiles</a> CTO, one of the participants mentioned this as “<em>Pay when you don&#8217;t use</em>” <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li><a href="https://www.mturk.com/mturk/welcome">Amazon Mechanical turk</a> – It is work force in the cloud. I need to research, what is needed to join this work force <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
<p>Jinesh also mentioned about EBS snapshot and EBS load balancing. To understand most of these items I try to find an analogy out of the things I know. So, I think EBS snapshot should be like a virtual machine snapshot but former is all about data in S3.</p>
<p>We had a good time playing in clouds. Thanks to Amazon, for giving us a temporary account to play with clouds. After installing <a href="https://addons.mozilla.org/en-US/firefox/addon/3247">S3Fox</a> a Firefox plug-in, working with S3 is almost like working in windows explorer as shown in Figure 1</p>
<div id="attachment_600" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-600" href="http://veechand.wordpress.com/2009/11/11/my-experiences-with-amazon-web-services-workshop/pic1/"><img class="size-medium wp-image-600 " title="S3 Fox" src="http://veechand.files.wordpress.com/2009/11/pic1.jpg?w=300&#038;h=138" alt="S3 Fox" width="300" height="138" /></a><p class="wp-caption-text">Figure 1 - View of S3Fox</p></div>
<p>You can create buckets by right clicking on the cloud area (right upper part of the window). A bucket (directory) is a container that contains objects (files). Clicking on create directory shows a new window for entering bucket name and its location details as shown in Figure 2</p>
<div id="attachment_602" class="wp-caption aligncenter" style="width: 261px"><a rel="attachment wp-att-602" href="http://veechand.wordpress.com/2009/11/11/my-experiences-with-amazon-web-services-workshop/pic3/"><img class="size-full wp-image-602   " title="Creating Bucket" src="http://veechand.files.wordpress.com/2009/11/pic3.jpg?w=251&#038;h=201" alt="Creating Bucket" width="251" height="201" /></a><p class="wp-caption-text">Figure 2 - Creating Bucket</p></div>
<div style="width:425px;text-align:left;">As the buckets are created you can go into any of those buckets and upload files from local folder to those buckets thereby to S3 clouds. It is also possible to change access permission of the files in the cloud as you do for files in windows</p>
<div id="attachment_610" class="wp-caption aligncenter" style="width: 478px"><a rel="attachment wp-att-610" href="http://veechand.wordpress.com/2009/11/11/my-experiences-with-amazon-web-services-workshop/pic4-2/"><img class="size-full wp-image-610   " title="Editing ACL" src="http://veechand.files.wordpress.com/2009/11/pic41.jpg?w=468&#038;h=176" alt="Editing ACL" width="468" height="176" /></a><p class="wp-caption-text">FIgure 3 - Editing ACL</p></div>
<p>Once a file is available in the cloud you will be able to access globally using normal http or through the exposed APIs, provided you have permission.</p>
<p>Now it’s time to play with EC2. We have installed <a href="http://s3.amazonaws.com/ec2-downloads/elasticfox.xpi">Elastic Fox</a>, yet another Firefox plug-in to play with EC2. Using Elastic Fox anyone could create an instance of Windows/Ubuntu/LAMP/WordPress (anything you name) instances in no time. In Amazon jargon these are called as <a href="http://en.wikipedia.org/wiki/Amazon_Machine_Image">AMI, Amazon Machine Image</a>.</p>
<div id="attachment_615" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-615" href="http://veechand.wordpress.com/2009/11/11/my-experiences-with-amazon-web-services-workshop/pic5/"><img class="size-medium wp-image-615" title="ElasticFox listing AMI" src="http://veechand.files.wordpress.com/2009/11/pic5.jpg?w=300&#038;h=138" alt="ElasticFox listing AMI" width="300" height="138" /></a><p class="wp-caption-text">Figure 4 - ElasticFox listing AMI</p></div>
</div>
<div style="width:425px;text-align:left;">I created one Windows 2003 R2 Datacenter edition server and I am able to successfully RDP to it. I am on Cloud9 when I am working on EC2 cloud for the first time <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . I am able to successfully run windows update in the virtual server running on the cloud. Even from my home network (128Mbps) I am having a good user experience (no delays or hiccups) with EC2 clouds. I searched for a Windows 7 AMI but I am not able to get one <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . When you create an instance you will be able to assign access groups and also configure services that need to be started.   Here is a short video on how to create EC2 instances using ElasticFox</div>
<div style="width:425px;text-align:left;"><span style="text-align:center; display: block;"><a href="http://veechand.wordpress.com/2009/11/11/my-experiences-with-amazon-web-services-workshop/"><img src="http://img.youtube.com/vi/D4wtAFvQFp8/2.jpg" alt="" /></a></span></div>
<div style="width:425px;text-align:left;">After seeing all this, I swear in future (not too far) there won’t be any system administrators, everyone will be cloud administrators. In no time I thought this, Jinesh told us about <a href="http://www.slideshare.net/jesserobbins/using-chef-for-automated-infrastructure-in-the-cloud">Chef tool</a> which is mainly designed for system administrators.</div>
<div style="width:425px;text-align:left;">
<p>Here are some of sites that use AWS</p>
<ul>
<li><a href="http://www.vembu.com/">www.vembu.com</a> – It offers free online backup at <a href="http://home.vembu.com/">home.vembu.com</a></li>
<li><a href="http://www.hungama.com/">Hungama.com</a> – One stop shop for entertainment</li>
<li><a href="http://animoto.com/">animoto.com</a> – Give a bunch of photo and a music file, they will create video for you. They say it is “End of Slide shows”</li>
</ul>
</div>
<div style="width:425px;text-align:left;">
<p>and many more like <a href="http://www.salesforce.com/">Salesforce.com</a>, <a href="http://8kmiles.com/">8kmiles.com</a>. Some other resources worth mentioning here are <a href="http://www.eucalyptus.com/">Eucalyptus</a> (analogous to EC2), Walrun (analogous to S3) and <a href="http://hadoop.apache.org/">Apache Hadoop</a></p>
<p>Before ending the workshop Jinesh has taken us through the “Migration Guidelines” and “Best Practices” that we need to follow when we work on cloud. Very few items, from the top of my head</p>
<ol>
<li>First migrate all your static contents to the cloud</li>
<li>If you backup on tape drives then you can export it to Amazon S3 storage. Amazon provides an export backup offer, where you ship the entire content in hard disk to Amazon and Amazon will load it in to the S3. This is extremely useful for users who are starting with S3 and having large amount of data to be exported to S3 but with limited network bandwidth</li>
<li>Migrate you application modules to EC2 instances, definitely after doing POC</li>
<li>Create Amazon SQS to interface between your EC2 instances</li>
<li>Create proxies to interface with some legacy applications</li>
</ol>
</div>
<p><strong>Warning</strong>: These are really very few that are on top of my head and they might not be 100% perfect too. So I request you to take this as keys and search for more in Google. I also heard that Jinesh is writing white papers on these topics. So keep watch on that too.</p>
<div style="width:425px;text-align:left;">
<p>After the conference we had a short un-conference section from <a href="http://railsfactory.com/">RailsFactory</a>, <a href="http://www.8kmiles.com/">8kmiles</a>, <a href="http://www.csscorp.com/">CSS corp</a>, <a href="http://www.marketsimplified.com/">Market Simplified</a>, <a href="http://www.xlsoft.com/">XlSoft</a>, <a href="http://hover.in/">Hover.in</a>, <a href="http://www.vembu.com/">Vembu</a> and <a href="http://www.anantsol.com/">Anantara</a> representatives. We ended up the section with a nice cool video, which you too should watch (be sure you listen to lyrics, they are shown at the bottom too)</p>
<p><span style="text-align:center; display: block;"><a href="http://veechand.wordpress.com/2009/11/11/my-experiences-with-amazon-web-services-workshop/"><img src="http://img.youtube.com/vi/Miv3Y42Fv44/2.jpg" alt="" /></a></span></p>
<p>Hope the blog is informative. Without your feedback the blog is not complete, so please comment on your feedback. I will feel guilty if I close this without thanking my friend Sree for making me aware of this event. Thanks Sree!!</p>
</div>
<p style="text-align:left;" class="getsocial"><a title="Add to Facebook" href="http://www.facebook.com/sharer.php?u=http://veechand.wordpress.com/2009/11/11/my-experiences-with-amazon-web-services-workshop" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4012.png" alt="Add to Facebook" /></a><a title="Add to Newsvine" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F11%2Fmy-experiences-with-amazon-web-services-workshop&amp;h=My%20experiences%20with%20AWS%20Chennai%20workshop" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4022.png" alt="Add to Newsvine" /></a><a title="Add to Digg" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F11%2Fmy-experiences-with-amazon-web-services-workshop&amp;title=My%20experiences%20with%20AWS%20Chennai%20workshop" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4032.png" alt="Add to Digg" /></a><a title="Add to Del.icio.us" href="http://del.icio.us/post?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F11%2Fmy-experiences-with-amazon-web-services-workshop&amp;title=My%20experiences%20with%20AWS%20Chennai%20workshop" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4042.png" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F11%2Fmy-experiences-with-amazon-web-services-workshop&amp;title=My%20experiences%20with%20AWS%20Chennai%20workshop" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4052.png" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" href="http://reddit.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F11%2Fmy-experiences-with-amazon-web-services-workshop&amp;title=My%20experiences%20with%20AWS%20Chennai%20workshop" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4062.png" alt="Add to Reddit" /></a><a title="Add to Blinklist" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F11%2Fmy-experiences-with-amazon-web-services-workshop&amp;Title=My%20experiences%20with%20AWS%20Chennai%20workshop" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4072.png" alt="Add to Blinklist" /></a><a title="Add to Twitter" href="http://twitter.com/home/?status=My%20experiences%20with%20AWS%20Chennai%20workshop+%40+http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F11%2Fmy-experiences-with-amazon-web-services-workshop" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4082.png" alt="Add to Twitter" /></a><a title="Add to Technorati" href="http://www.technorati.com/faves?add=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F11%2Fmy-experiences-with-amazon-web-services-workshop" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4092.png" alt="Add to Technorati" /></a><a title="Add to Furl" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F11%2Fmy-experiences-with-amazon-web-services-workshop&amp;t=My%20experiences%20with%20AWS%20Chennai%20workshop" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4102.png" alt="Add to Furl" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veechand.wordpress.com/598/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veechand.wordpress.com/598/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veechand.wordpress.com/598/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veechand.wordpress.com/598/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veechand.wordpress.com/598/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veechand.wordpress.com/598/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veechand.wordpress.com/598/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veechand.wordpress.com/598/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veechand.wordpress.com/598/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veechand.wordpress.com/598/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=598&subd=veechand&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://veechand.wordpress.com/2009/11/11/my-experiences-with-amazon-web-services-workshop/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86b7deee7b6c29ee12158ba3455022e0?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">veeru</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/11/pic1.jpg?w=300" medium="image">
			<media:title type="html">S3 Fox</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/11/pic3.jpg" medium="image">
			<media:title type="html">Creating Bucket</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/11/pic41.jpg" medium="image">
			<media:title type="html">Editing ACL</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/11/pic5.jpg?w=300" medium="image">
			<media:title type="html">ElasticFox listing AMI</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/D4wtAFvQFp8/2.jpg" medium="image" />

		<media:content url="http://img.youtube.com/vi/Miv3Y42Fv44/2.jpg" medium="image" />

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4012.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4022.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4032.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4042.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4052.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4062.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4072.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4082.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4092.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4102.png" medium="image">
			<media:title type="html">Add to Furl</media:title>
		</media:content>
	</item>
		<item>
		<title>Playing with REST annotations</title>
		<link>http://veechand.wordpress.com/2009/11/09/playing-with-rest-annotations/</link>
		<comments>http://veechand.wordpress.com/2009/11/09/playing-with-rest-annotations/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 19:20:42 +0000</pubDate>
		<dc:creator>Veerabahu</dc:creator>
				<category><![CDATA[techinal]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[rest jersey]]></category>

		<guid isPermaLink="false">http://veechand.wordpress.com/?p=541</guid>
		<description><![CDATA[how to get user inputs in REST<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=541&subd=veechand&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In the <a href="http://veechand.wordpress.com/2009/10/29/getting-started-with-rest/">last article </a>in addition to setting up our IDE for writing REST services we have also got friendly with four basic annotations. In this article we will look in to some of the other commonly used annotations in REST.<span id="more-541"></span></p>
<p>The example of greeting a user is used through this article to help you comprehend and assimilate the tips provided in this article. Let us start by creating the form</p>
<pre class="brush: xml;">
&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=ISO-8859-1&quot;
	pageEncoding=&quot;ISO-8859-1&quot;%&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html&gt;
  &lt;head&gt;
     &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&gt;
     &lt;title&gt;Playing with Annotations&lt;/title&gt;
   &lt;/head&gt;
   &lt;body&gt;
      &lt;form method=&quot;post&quot; action=&quot;/PracticeREST/rest/helloworld/ &quot;&gt;
         &lt;label&gt;User Name:&lt;/label&gt;
         &lt;input type=&quot;text&quot; name=&quot;name&quot;&gt;&lt;/input&gt;
         &lt;input type=&quot;submit&quot; value=&quot;submit&quot;&gt;&lt;/input&gt;
      &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>On submit, the form will be submitted as a POST request to the REST service deployed at <em>PracticeREST/rest/greetings/</em> (same service that we wrote in our last article with certain modifications). The REST service should welcome the entered user. Pretty similar to the service that we saw in our last article with the following changes,</p>
<ol>
<li>Have to handle POST request rather than GET as we did previously</li>
<li>Have to get the user name from form</li>
</ol>
<p>Once we complete this, we will also look in to other ways of getting the user name, for example from <em>URL </em>and <em>HTTPServletRequest </em>object.</p>
<p><strong>Manipulating Form Attributes:</strong></p>
<p>For handling POST request, the POJO method needs to be decorated with @POST annotation as shown below,</p>
<pre class="brush: java;">
@POST
public String sayHello(){
	//implement the business logic here
}
</pre>
<p>REST provides two annotations @MultivaluedMap and @FormParam to manipulate form attributes.  Using @FormParam(“param name”) we will be able to get the value of a particular form parameter as shown below,</p>
<pre class="brush: java;">
public String sayHello(@FormParam(&quot;name&quot;) @DefaultValue(&quot;NoName&quot;) String name ){
	return &quot;Howdy &quot;+name+&quot; !! Welcome to Jersey REST.&quot;;
}
</pre>
<p>In addition to @FormParam, REST provides @MultivaluedMap annotation to iterate over all the form parameters as shown below,</p>
<pre class="brush: java;">
public String sayHello(MultivaluedMap&lt;String, String&gt; formParams){
	for (String key : formParams.keySet()) {
			formparameters = formparameters + formParams.get(key);
		}
		formparameters += &quot;&lt;br&gt; Value got using FormParam &quot; + userName;
	System.out.println(formparameters);
}
</pre>
<p><strong>Note:</strong> Form parameters that has name attribute can only be manipulated with @MultivaluedMap  and @FormParam annotations</p>
<p><strong>Other ways to get user inputs</strong></p>
<p>In addition to the above annotations which directly work on form parameters, REST provides @PathParam, @Context annotation to get user inputs.</p>
<p><strong>Using @PathParam</strong></p>
<p>To illustrate this, let us add a new link to our index.jsp as shown below</p>
<pre class="brush: xml;">
…..
&lt;input type=&quot;text&quot; name=&quot;name&quot;&gt;&lt;/input&gt;
&lt;a href=&quot;/PracticeREST/rest/helloworld/veechand&quot;&gt;Click Me&lt;/a&gt;
</pre>
<p>Clicking on the link will direct the user to the service at <em>/PracticeREST/rest/helloworld/veechand</em> as a GET request. Assume that the username in the link, namely veechand, is dynamically populated using the logged in user. In this case our service URL should be something like <em>/PracticeREST/rest/helloworld/[variable]</em> and our business logic should able to get and process on the variable. @PathParam helps us in doing this,</p>
<pre class="brush: java;">
@Path(&quot;/helloworld/{username}&quot;)
public String sayHello(@PathParam(&quot;username&quot;) @DefaultValue(&quot;NoName&quot;) String name ){
		return &quot;Howdy &quot;+name+&quot; !! Welcome to Jersey REST.&quot;;
}
</pre>
<p>1. @PATH annotation has a variable embedded in it. This variable will be substituted at run time.  Variable have to be represented in curly braces ‘{‘<br />
2. Value of the URI variables can be got using @PathParam(’[variable name]&#8216;). This annotation could take @DefaultValue to assign a default value to the variable.</p>
<p><strong>Using @Context</strong></p>
<p>@Context can be used for obtaining and processing information about the application deployment and individual request. Using @Context we can get handle to HttpHeaders, Request, SecurityContext, HttpServletConfig, ServletContext, HttpServletRequest, HttpServletResponse and EJB container details like @EJB, @EJBs, @WebServiceRef, @WebServiceRefs, @PersistenceContext, @PersistenceContexts, @PersistenceUnit and @PersistenceUnits. So using @Context a handle to Request object can be obtained and manipulated to get the needed parameters</p>
<pre class="brush: java;">
public String post(@Context HttpServletRequest req) {
          String username = req.getParameter(key)
}
</pre>
<p>Hopefully you&#8217;ve found this tutorial interesting and this has been useful to you. Feel free to reuse this code elsewhere in your projects and chime in here if you are running into difficulties. Questions? Nice things to say? Criticisms? Hit the comments section and leave me a comment. Happy coding!</p>
<p style="text-align:left;" class="getsocial"><a title="Add to Facebook" href="http://www.facebook.com/sharer.php?u=http://veechand.wordpress.com/2009/11/09/playing-with-rest-annotations" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4014.png" alt="Add to Facebook" /></a><a title="Add to Newsvine" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F09%2Fplaying-with-rest-annotations&amp;h=Playing%20with%20REST%20annotations" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4024.png" alt="Add to Newsvine" /></a><a title="Add to Digg" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F09%2Fplaying-with-rest-annotations&amp;title=Playing%20with%20REST%20annotations" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4034.png" alt="Add to Digg" /></a><a title="Add to Del.icio.us" href="http://del.icio.us/post?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F09%2Fplaying-with-rest-annotations&amp;title=Playing%20with%20REST%20annotations" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4044.png" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F09%2Fplaying-with-rest-annotations&amp;title=Playing%20with%20REST%20annotations" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4054.png" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" href="http://reddit.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F09%2Fplaying-with-rest-annotations&amp;title=Playing%20with%20REST%20annotations" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4064.png" alt="Add to Reddit" /></a><a title="Add to Blinklist" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F09%2Fplaying-with-rest-annotations&amp;Title=Playing%20with%20REST%20annotations" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4074.png" alt="Add to Blinklist" /></a><a title="Add to Twitter" href="http://twitter.com/home/?status=Playing%20with%20REST%20annotations+%40+http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F09%2Fplaying-with-rest-annotations" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4084.png" alt="Add to Twitter" /></a><a title="Add to Technorati" href="http://www.technorati.com/faves?add=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F09%2Fplaying-with-rest-annotations" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4094.png" alt="Add to Technorati" /></a><a title="Add to Furl" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F11%2F09%2Fplaying-with-rest-annotations&amp;t=Playing%20with%20REST%20annotations" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4104.png" alt="Add to Furl" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veechand.wordpress.com/541/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veechand.wordpress.com/541/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veechand.wordpress.com/541/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veechand.wordpress.com/541/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veechand.wordpress.com/541/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veechand.wordpress.com/541/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veechand.wordpress.com/541/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veechand.wordpress.com/541/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veechand.wordpress.com/541/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veechand.wordpress.com/541/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=541&subd=veechand&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://veechand.wordpress.com/2009/11/09/playing-with-rest-annotations/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86b7deee7b6c29ee12158ba3455022e0?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">veeru</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4014.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4024.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4034.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4044.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4054.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4064.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4074.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4084.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4094.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4104.png" medium="image">
			<media:title type="html">Add to Furl</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting started with REST</title>
		<link>http://veechand.wordpress.com/2009/10/29/getting-started-with-rest/</link>
		<comments>http://veechand.wordpress.com/2009/10/29/getting-started-with-rest/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 16:39:17 +0000</pubDate>
		<dc:creator>Veerabahu</dc:creator>
				<category><![CDATA[techinal]]></category>
		<category><![CDATA[rest jersey]]></category>

		<guid isPermaLink="false">http://veechand.wordpress.com/?p=464</guid>
		<description><![CDATA[Introduction 
  REST, acronym for Representational State Transfer is coined by Roy Fielding to represent architectural style of networked systems. This is not a standard but an architectural style for an application that is based on different standards like HTTP, XML, URL, MIME types.  JAX-RS specification, JSR 311 defines a set of java APIs [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=464&subd=veechand&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Introduction </strong></p>
<p><strong> </strong> <a href="http://www.xfront.com/REST-Web-Services.html" target="_blank">REST</a>, acronym for Representational State Transfer is coined by <a href="http://www.ics.uci.edu/~fielding/" target="_blank">Roy Fielding</a> to represent architectural style of networked systems. This is not a standard but an architectural style for an application that is based on different standards like HTTP, XML, URL, MIME types.  JAX-RS specification, <a href="https://jsr311.dev.java.net/nonav/releases/1.0/spec/index.html">JSR 311</a> defines a set of java APIs for development of RESTful web services and RESTful java application.  <a href="https://jersey.dev.java.net/use/getting-started.html">Sun Jersey</a>, <a href="http://www.jboss.org/resteasy/">JBoss RESTEasy</a>, <a href="http://cwiki.apache.org/CXF/">Apache CXF</a> provides implementation for JSR 311. In this article we will look at the steps needed to setup Eclipse IDE for developing REST application using Jersey. We will also write our first HelloWorld service. <span id="more-464"></span></p>
<p><strong>Step 1 : Downloading needed jars</strong></p>
<p>The following jars needed to be available at compile time and runtime,</p>
<ul>
<li>jersey-core*.jar</li>
<li>jersey-server*.jar</li>
<li>jsr311-api-1.1.jar</li>
<li>asm*.jar</li>
</ul>
<p>All these jars can be downloaded in zip format at <a href="http://download.java.net/maven/2/com/sun/jersey/jersey-archive/">http://download.java.net/maven/2/com/sun/jersey/jersey-archive/</a></p>
<p><strong>Note</strong>: Setup procedure is different for maven users and not covered in this blog.</p>
<p><strong>Step 2 : Creating a Dynamic Web Project</strong></p>
<p>Follow the step 2 mentioned in <a href="http://veechand.wordpress.com/2009/09/16/4-easy-steps-to-load-strut2inaction-source/">http://veechand.wordpress.com/2009/09/16/4-easy-steps-to-load-strut2inaction-source/</a></p>
<p><strong>Note</strong>: Have the project name as PracticeREST instead of Struts2InAction</p>
<p><strong>Step 3 : Configuring Build Path</strong></p>
<p>Right click on the project. Choose <em>properties </em>and then<em> Java Build Path &gt; Libraries</em>. Using “<em>Add External Jars</em>” option add the four jars downloaded in step 1</p>
<div id="attachment_465" class="wp-caption aligncenter" style="width: 478px"><a rel="attachment wp-att-465" href="http://veechand.wordpress.com/2009/10/29/getting-started-with-rest/restfigure1/"><img class="size-full wp-image-465" title="Figure 1 : Adding REST Jars" src="http://veechand.files.wordpress.com/2009/10/restfigure1.jpg?w=468&#038;h=424" alt="Figure 1 : Adding REST Jars" width="468" height="424" /></a><p class="wp-caption-text">Figure 1 : Adding REST Jars</p></div>
<p>Also, change the Default output folder to classes directory (create newly) under WEB-INF folder. This has to be done in <em>Source </em>tab as shown below</p>
<div id="attachment_466" class="wp-caption aligncenter" style="width: 478px"><a rel="attachment wp-att-466" href="http://veechand.wordpress.com/2009/10/29/getting-started-with-rest/restfigure2/"><img class="size-full wp-image-466" title="Figure 2 - Changing Default output folder" src="http://veechand.files.wordpress.com/2009/10/restfigure2.jpg?w=468&#038;h=434" alt="Figure 2 - Changing Default output folder" width="468" height="434" /></a><p class="wp-caption-text">Figure 2 - Changing Default output folder</p></div>
<p><strong>Step 4 : Configuring REST servlets</strong></p>
<p>To load Jersey servlets dispatcher add the following entries to PracticeREST/WebContent/WEB-INF/web.xml</p>
<pre><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:small;"><span style="line-height:19px;white-space:normal;"><span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;font-size:small;"><span style="line-height:18px;white-space:pre;">&lt;servlet&gt;</span></span></span></span>
<span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:small;"><span style="line-height:19px;white-space:normal;"><span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;font-size:small;"> </span></span></span>  &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
  &lt;servlet-class&gt;<span style="text-decoration:underline;">com</span>.sun.jersey.<span style="text-decoration:underline;">spi</span>.container.<span style="text-decoration:underline;">servlet</span>.ServletContainer&lt;/servlet-class&gt;
&lt;/servlet&gt;
&lt;servlet-mapping&gt;
 &lt;servlet-name&gt;Jersey Web Application&lt;/servlet-name&gt;
 &lt;url-pattern&gt;/myrest/*&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
<span style="font-size:small;">&lt;/servlet&gt;</span></pre>
<p>Now all our REST web services will be available through …/rest/[resource]</p>
<p><strong>Step 5 : Writing our first “Greetings” service</strong></p>
<p>Create a new class my.practice.rest.Greetings and paste the below code</p>
<p><code><br />
package my.practice.rest;<br />
import javax.annotation.Resource;<br />
import javax.ws.rs.DefaultValue;<br />
import javax.ws.rs.GET;<br />
import javax.ws.rs.Path;<br />
import javax.ws.rs.QueryParam;<br />
/*<br />
* @author veechand<br />
*/<br />
@Path("/sayhello/")<br />
public class Greetings {<br />
@GET<br />
public String sayHello(@QueryParam("name") @DefaultValue ("NoName") String name ){<br />
return "Howdy "+name+" !! Welcome to Jersey REST.";<br />
}<br />
}<br />
</code></p>
<p>The meaning of the annotations used in the above code are as below</p>
<p>&nbsp;</p>
<table border="1">
<tbody>
<tr>
<th>Annotation</th>
<th> Description</th>
<th>Values</th>
</tr>
<tr>
<td>@Path</td>
<td>Identifies the URI path that serves a request. This corresponds to javax.ws.rs.Path package</td>
<td>Our Greeting service will be available through http://hostaddress:port-number/PracticeREST/rest/sayhello</td>
</tr>
<tr>
<td>@Get</td>
<td>Identifies the method that serves the Get request</td>
<td>This corresponds to javax.ws.rs.Get package</td>
</tr>
<tr>
<td>@QueryParam</td>
<td>Maps between the URL parameter and a java variable. This corresponds to javax.ws.rs.QueryParam package.</td>
<td>In our case the “name” parameter in URL is mapped to java variable, name</td>
</tr>
<tr>
<td>@DefaultValue</td>
<td>Defines the default value. This value will be assigned to the variable if URL doesn’t have the specified parameter.</td>
<td>In our case NoName will be assigned by default.</td>
</tr>
</tbody>
</table>
<p><strong>Step 6 : Testing our Greetings Service</strong></p>
<p>You will be able to access the Greetings service by launching   <a href="http://hostaddress:port-number/PracticeREST/rest/sayhello?name=veechand">http://hostaddress:port-number/PracticeREST/rest/sayhello?name=veechand</a> in your favorite http client</p>
<p><strong> Note</strong>: You have to replace hostaddress and port-number with corresponding values.</p>
<div id="attachment_534" class="wp-caption aligncenter" style="width: 478px"><a rel="attachment wp-att-534" href="http://veechand.wordpress.com/2009/10/29/getting-started-with-rest/restfigure3-2/"><img class="size-full wp-image-534" title="Figure 3 - Result" src="http://veechand.files.wordpress.com/2009/10/restfigure31.jpg?w=468&#038;h=349" alt="Figure 3 - Result" width="468" height="349" /></a><p class="wp-caption-text">Figure 3 - Result</p></div>
<p><strong>Closing Notes:</strong></p>
<p>List of principles of a REST web design can be read at <a href="http://www.xfront.com/REST-Web-Services.html">http://www.xfront.com/REST-Web-Services.html</a>. Yes, we are violating the 2<sup>nd</sup> principle. I leave fixing this violation to readers. Comment if you have any issues in getting through it.</p>
<p>Keep watching for more write ups on Jersey REST</p>
<p style="text-align:left;" class="getsocial"><a title="Add to Facebook" href="http://www.facebook.com/sharer.php?u=http://veechand.wordpress.com/2009/10/29/getting-started-with-rest" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4011.png" alt="Add to Facebook" /></a><a title="Add to Newsvine" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F10%2F29%2Fgetting-started-with-rest&amp;h=Getting%20started%20with%20REST" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4021.png" alt="Add to Newsvine" /></a><a title="Add to Digg" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F10%2F29%2Fgetting-started-with-rest&amp;title=Getting%20started%20with%20REST" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4031.png" alt="Add to Digg" /></a><a title="Add to Del.icio.us" href="http://del.icio.us/post?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F10%2F29%2Fgetting-started-with-rest&amp;title=Getting%20started%20with%20REST" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4041.png" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F10%2F29%2Fgetting-started-with-rest&amp;title=Getting%20started%20with%20REST" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4051.png" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" href="http://reddit.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F10%2F29%2Fgetting-started-with-rest&amp;title=Getting%20started%20with%20REST" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4061.png" alt="Add to Reddit" /></a><a title="Add to Blinklist" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F10%2F29%2Fgetting-started-with-rest&amp;Title=Getting%20started%20with%20REST" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4071.png" alt="Add to Blinklist" /></a><a title="Add to Twitter" href="http://twitter.com/home/?status=Getting%20started%20with%20REST+%40+http%3A%2F%2Fveechand.wordpress.com%2F2009%2F10%2F29%2Fgetting-started-with-rest" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4081.png" alt="Add to Twitter" /></a><a title="Add to Technorati" href="http://www.technorati.com/faves?add=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F10%2F29%2Fgetting-started-with-rest" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4091.png" alt="Add to Technorati" /></a><a title="Add to Furl" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F10%2F29%2Fgetting-started-with-rest&amp;t=Getting%20started%20with%20REST" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4101.png" alt="Add to Furl" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veechand.wordpress.com/464/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veechand.wordpress.com/464/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veechand.wordpress.com/464/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veechand.wordpress.com/464/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veechand.wordpress.com/464/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veechand.wordpress.com/464/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veechand.wordpress.com/464/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veechand.wordpress.com/464/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veechand.wordpress.com/464/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veechand.wordpress.com/464/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=464&subd=veechand&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://veechand.wordpress.com/2009/10/29/getting-started-with-rest/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86b7deee7b6c29ee12158ba3455022e0?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">veeru</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/10/restfigure1.jpg" medium="image">
			<media:title type="html">Figure 1 : Adding REST Jars</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/10/restfigure2.jpg" medium="image">
			<media:title type="html">Figure 2 - Changing Default output folder</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/10/restfigure31.jpg" medium="image">
			<media:title type="html">Figure 3 - Result</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4011.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4021.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4031.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4041.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4051.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4061.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4071.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4081.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4091.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4101.png" medium="image">
			<media:title type="html">Add to Furl</media:title>
		</media:content>
	</item>
		<item>
		<title>4 easy steps to load Strut2InAction source</title>
		<link>http://veechand.wordpress.com/2009/09/16/4-easy-steps-to-load-strut2inaction-source/</link>
		<comments>http://veechand.wordpress.com/2009/09/16/4-easy-steps-to-load-strut2inaction-source/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 11:22:53 +0000</pubDate>
		<dc:creator>Veerabahu</dc:creator>
				<category><![CDATA[techinal]]></category>

		<guid isPermaLink="false">http://veechand.wordpress.com/?p=440</guid>
		<description><![CDATA[eclipse Struts2InAction<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=440&subd=veechand&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Currently I am reading <a href="http://www.manning.com/dbrown/">Struts 2 in Action</a>. This is my second book from Manning publication. My first book was <a href="http://www.manning.com/bibeault2/">JQuery in Action</a> which is awesome.  As I completed the second chapter in Struts 2 I like to try out the sample HelloWorld program.  So I downloaded the source code from <a href="http://www.manning.com/dbrown/SampleApplication.zip">manning website</a>. I am able to play with HelloWorld in few minutes by deploying (copying) the downloaded war inside Tomcat 5.5.  However I also want to make a development setup in my eclipse so that I could try out certain things after changing the downloaded source. Unfortunately I am not able to make this easily. <span id="more-440"></span>My search for a document explaining the step to import the downloaded source in to eclipse also went in vain. After a struggle of few hours, got the downloaded source integrated with Eclipse. Today, we&#8217;re going to take a closer look at the steps to load the downloaded source in to eclipse.</p>
<p><strong>Note:</strong> Below steps explains about loading Struts2InAction (war). The same applies to HelloWorld.</p>
<h3>Step 1 – Extract the war file</h3>
<p>Open the war file using some extraction utility like Winrar. Extract the contents in to <strong>Struts2InAction</strong>(create new) directory in your workspace.</p>
<div id="attachment_441" class="wp-caption aligncenter" style="width: 477px"><a rel="attachment wp-att-441" href="http://veechand.wordpress.com/2009/09/16/4-easy-steps-to-load-strut2inaction-source/struts2step1/"><img class="size-full wp-image-441" title="Figure 1 - Extracting" src="http://veechand.files.wordpress.com/2009/09/struts2step1.jpg?w=467&#038;h=181" alt="Figure 1 - Extracting" width="467" height="181" /></a><p class="wp-caption-text">Figure 1 - Extracting</p></div>
<h3>Step 2 – Create a Eclipse project</h3>
<p>We need to create a <strong><em>Dynamic Web Project</em></strong> in eclipse.</p>
<div id="attachment_444" class="wp-caption aligncenter" style="width: 478px"><a rel="attachment wp-att-444" href="http://veechand.wordpress.com/2009/09/16/4-easy-steps-to-load-strut2inaction-source/struts2step2/"><img class="size-full wp-image-444" title="Figure 2 - Creating a new project" src="http://veechand.files.wordpress.com/2009/09/struts2step2.jpg?w=468&#038;h=244" alt="Figure 2 - Creating a new project" width="468" height="244" /></a><p class="wp-caption-text">Figure 2 - Creating a new project</p></div>
<p>Enter the project name as “<strong><em>Struts2InAction”. </em><span style="font-weight:normal;">Select the directory created in Step 1 as value to project contents</span></strong></p>
<p><strong><span style="font-weight:normal;"> </span></strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<div id="attachment_445" class="wp-caption aligncenter" style="width: 478px"><a rel="attachment wp-att-445" href="http://veechand.wordpress.com/2009/09/16/4-easy-steps-to-load-strut2inaction-source/struts2step3/"><img class="size-full wp-image-445" title="Figure 3 - Dynamic Project" src="http://veechand.files.wordpress.com/2009/09/struts2step3.jpg?w=468&#038;h=482" alt="Figure 3 - Dynamic Project" width="468" height="482" /></a><p class="wp-caption-text">Figure 3 - Dynamic Project</p></div>
<p><span style="font-weight:normal;">Click Finish. A new project will be created with all the source code imported as shown in the below figure, </span></p>
<p><span style="font-weight:normal;"> </span></p>
<div id="attachment_446" class="wp-caption aligncenter" style="width: 242px"><a rel="attachment wp-att-446" href="http://veechand.wordpress.com/2009/09/16/4-easy-steps-to-load-strut2inaction-source/struts2step4/"><img class="size-full wp-image-446" title="Figure 4 - Wrong directory structure" src="http://veechand.files.wordpress.com/2009/09/struts2step4.jpg?w=232&#038;h=383" alt="Figure 4 - Wrong directory structure" width="232" height="383" /></a><p class="wp-caption-text">Figure 4 - Wrong directory structure</p></div>
<h3>Step 3: Files re-arrangement</h3>
<p>We need to make certain re-arrangements before successfully running the applications.</p>
<ol>
<li>Copy all Chapter* directories in to WebContent directory</li>
<li>Copy menu, images in to WebContent directory</li>
<li>Copy index.html in to WebContent directory</li>
<li>Replace Struts2InAction/WebContent/WEB-INF with Struts2InAction/WEB-INF</li>
</ol>
<p><strong>Note:</strong> Do the above steps using windows explorer. After copying refresh the project in eclipse.</p>
<p>Once the above steps are done, the workspace will be re-structured as shown below</p>
<div id="attachment_448" class="wp-caption aligncenter" style="width: 245px"><a rel="attachment wp-att-448" href="http://veechand.wordpress.com/2009/09/16/4-easy-steps-to-load-strut2inaction-source/struts2step5-2/"><img class="size-full wp-image-448" title="Figure 5 - Project Structure" src="http://veechand.files.wordpress.com/2009/09/struts2step51.jpg?w=235&#038;h=383" alt="Figure 5 - Project Structure" width="235" height="383" /></a><p class="wp-caption-text">Figure 5 - Project Structure</p></div>
<h3>Step 4 – Run and Have fun</h3>
<p>Now on a single click the application will be running within eclipse.</p>
<div id="attachment_450" class="wp-caption aligncenter" style="width: 477px"><a rel="attachment wp-att-450" href="http://veechand.wordpress.com/2009/09/16/4-easy-steps-to-load-strut2inaction-source/struts2step6/"><img class="size-full wp-image-450" title="Figure 6 - Running Application" src="http://veechand.files.wordpress.com/2009/09/struts2step61.jpg?w=467&#038;h=363" alt="Figure 6 - Running Application" width="467" height="363" /></a><p class="wp-caption-text">Figure 6 - Running Application</p></div>
<p>Hope this blog helps you in saving your valuable time. The same procedure applies to creation of any “Dynamic Web Project”. Let me know if you find more easier way to achieve the same.</p>
<p class="getsocial" style="text-align:left;"><a title="Add to Facebook" href="http://www.facebook.com/sharer.php?u=http://veechand.wordpress.com/2009/09/14/440" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4015.png" alt="Add to Facebook" /></a><a title="Add to Newsvine" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F09%2F14%2F440&amp;h=4%20easy%20steps%20to%20load%20Strut2InAction%20source" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4025.png" alt="Add to Newsvine" /></a><a title="Add to Digg" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F09%2F14%2F440&amp;title=4%20easy%20steps%20to%20load%20Strut2InAction%20source" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4035.png" alt="Add to Digg" /></a><a title="Add to Del.icio.us" href="http://del.icio.us/post?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F09%2F14%2F440&amp;title=4%20easy%20steps%20to%20load%20Strut2InAction%20source" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4045.png" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F09%2F14%2F440&amp;title=4%20easy%20steps%20to%20load%20Strut2InAction%20source" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4055.png" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" href="http://reddit.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F09%2F14%2F440&amp;title=4%20easy%20steps%20to%20load%20Strut2InAction%20source" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4065.png" alt="Add to Reddit" /></a><a title="Add to Blinklist" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F09%2F14%2F440&amp;Title=4%20easy%20steps%20to%20load%20Strut2InAction%20source" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4075.png" alt="Add to Blinklist" /></a><a title="Add to Twitter" href="http://twitter.com/home/?status=4%20easy%20steps%20to%20load%20Strut2InAction%20source+%40+http%3A%2F%2Fveechand.wordpress.com%2F2009%2F09%2F14%2F440" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4085.png" alt="Add to Twitter" /></a><a title="Add to Technorati" href="http://www.technorati.com/faves?add=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F09%2F14%2F440" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4095.png" alt="Add to Technorati" /></a><a title="Add to Furl" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F09%2F14%2F440&amp;t=4%20easy%20steps%20to%20load%20Strut2InAction%20source" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4105.png" alt="Add to Furl" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veechand.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veechand.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veechand.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veechand.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veechand.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veechand.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veechand.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veechand.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veechand.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veechand.wordpress.com/440/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=440&subd=veechand&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://veechand.wordpress.com/2009/09/16/4-easy-steps-to-load-strut2inaction-source/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86b7deee7b6c29ee12158ba3455022e0?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">veeru</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/09/struts2step1.jpg" medium="image">
			<media:title type="html">Figure 1 - Extracting</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/09/struts2step2.jpg" medium="image">
			<media:title type="html">Figure 2 - Creating a new project</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/09/struts2step3.jpg" medium="image">
			<media:title type="html">Figure 3 - Dynamic Project</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/09/struts2step4.jpg" medium="image">
			<media:title type="html">Figure 4 - Wrong directory structure</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/09/struts2step51.jpg" medium="image">
			<media:title type="html">Figure 5 - Project Structure</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/09/struts2step61.jpg" medium="image">
			<media:title type="html">Figure 6 - Running Application</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4015.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4025.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4035.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4045.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4055.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4065.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4075.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4085.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4095.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4105.png" medium="image">
			<media:title type="html">Add to Furl</media:title>
		</media:content>
	</item>
		<item>
		<title>5 Little known SNMP secrets of the experts</title>
		<link>http://veechand.wordpress.com/2009/08/22/5-little-known-snmp-secrets-of-the-experts/</link>
		<comments>http://veechand.wordpress.com/2009/08/22/5-little-known-snmp-secrets-of-the-experts/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 19:09:44 +0000</pubDate>
		<dc:creator>Veerabahu</dc:creator>
				<category><![CDATA[techinal]]></category>
		<category><![CDATA[snmp]]></category>

		<guid isPermaLink="false">http://veechand.wordpress.com/?p=378</guid>
		<description><![CDATA[Tips on SNMP simple network management protocol<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=378&subd=veechand&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Simple Network Management Protocol (SNMP)</strong> is one of the widely used management protocol. SNMP has gained a huge advantage due to its ease of data retrieval and efficient use of network bandwidth. This blog aims to cover certain key points in SNMP (version 1 &amp; 2c). Some of these points are not explicitly said in the SNMP RFC. Hope the concepts discussed will be a good learning experience to you<span id="more-378"></span></p>
<h2>1. GetNext for SysName is SysName.0</h2>
<p>SNMP Protocol Data Unit (PDU) “<em>GetNext</em>” is used to get lexicographically next managed object from the Management Information Base (MIB). One could wrongly conclude that &#8220;GetNext&#8221; of SysName is SysLocation on a glance through the MIB (<a href="http://tools.cisco.com/Support/SNMP/do/BrowseOID.do?local=en&amp;translate=Translate&amp;objectInput=1.3.6.1.2.1.1">here</a>). However <a href="#figure1">Figure 1</a> displays the actual result.<br />
<a name="figure1"></a></p>
<p><a name="figure1"></a></p>
<div class="mceTemp mceIEcenter"><a name="figure1"></a>
<dl class="wp-caption aligncenter"><a name="figure1"></a>
<dt class="wp-caption-dt"><a rel="attachment wp-att-384" href="http://veechand.wordpress.com/2009/08/22/5-little-known-snmp-secrets-of-the-experts/figure1-2/"><img class="size-full wp-image-384" title="Figure 1 - GetNext" src="http://veechand.files.wordpress.com/2009/08/figure11.jpg?w=467&#038;h=99" alt="Figure 1 - GetNext" width="467" height="99" /></a></dt>
<dd class="wp-caption-dd">Figure 1 &#8211; GetNext</dd>
</dl>
</div>
<p>As shown, sysName.0 is lexicographically next to sysName. So even though sysName is leaf object only sysName.0 will have a value. So, <em>GetNext</em> will end up in getting sysName.0 and not sysLocation. This concept applies to any scalar object.</p>
<p><strong>Note:</strong> Scalar objects are those that that have only one instance.</p>
<h2>2. Tabular instances starts from 1 however Scalar instances start from 0</h2>
<p>The index for tabular objects, objects that have multiple instances, starts from 1. However index for scalar objects, objects that have only instance, starts from 0 (off course ends at 0 itself;)). <a href="#figure2">Figure 2</a> displays the output of ifIndex (tabular) and sysName (scalar) managed objects.<br />
<a name="figure2"></a></p>
<p><a name="figure2"></a></p>
<div class="mceTemp mceIEcenter"><a name="figure2"></a>
<dl class="wp-caption aligncenter"><a name="figure2"></a>
<dt class="wp-caption-dt"><a rel="attachment wp-att-389" href="http://veechand.wordpress.com/2009/08/22/5-little-known-snmp-secrets-of-the-experts/figure2/"><img class="size-full wp-image-389" title="Figure 2 - Tabular (vs) scalar instances" src="http://veechand.files.wordpress.com/2009/08/figure2.jpg?w=467&#038;h=107" alt="Figure 2 - Tabular (vs) scalar instances" width="467" height="107" /></a></dt>
<dd class="wp-caption-dd">Figure 2 &#8211; Tabular (vs) scalar instances</dd>
</dl>
</div>
<p>Henceforth, only snmpget on sysName.0 will return a value and snmpget on sysName will return an error.</p>
<h2>3. RowStatus automatically moves to Active after successful creation</h2>
<p>SNMP Version 2c defines a way to create a new row in a table. A new row can be created in tables that has a column of type ROWSTATUS. A new row can be created by giving values for all mandatory columns and setting ROWSTATUS column to “CreateAndGo(4)”. This will create a new row. If values for all mandatory columns are proper the ROWSTATUS value will be moved to “Active(1)”. However in certain cases, administrator needs to make a row active after certain period of time, say for cases like configuration changes. In such cases user needs to create row(s) with ROWSTATUS value as “CreateAndWait(5)”.  This will move the ROWSTATUS to “NotReady” or “NotInService” depending upon the value for other mandatory columns. As per the administrator intent, the row can be made active by setting the ROWSTATUS value to Active (1) at any point of time.</p>
<h3>4. Error Index and Error Status are always set to zero (0) in SNMPV2c</h3>
<p>SNMP version 2c is atomic, i.e. user will be able to get results for partial set of varbinds. In case of SNMP version 1, error will be returned when certain varbinds are wrong. A query made using SNMP version 1 and version 2c are as shown in <a href="#figure3">Figure 3</a> and <a href="#figure4">Figure 4</a><br />
<a name="figure3"></a></p>
<p><a name="figure3"></a></p>
<div class="mceTemp mceIEcenter"><a name="figure3"></a>
<dl class="wp-caption aligncenter"><a name="figure3"></a>
<dt class="wp-caption-dt"><a rel="attachment wp-att-394" href="http://veechand.wordpress.com/2009/08/22/5-little-known-snmp-secrets-of-the-experts/figure3/"><img class="size-full wp-image-394" title="Figure 3 - Using SNMP V1" src="http://veechand.files.wordpress.com/2009/08/figure3.jpg?w=468&#038;h=90" alt="Figure 3 - Using SNMP V1" width="468" height="90" /></a></dt>
<dd class="wp-caption-dd">Figure 3 &#8211; Using SNMP V1</dd>
</dl>
</div>
<p><a name="figure4"></a></p>
<div class="mceTemp mceIEcenter"><a name="figure4"></a>
<dl class="wp-caption aligncenter"><a name="figure4"></a>
<dt class="wp-caption-dt"><a rel="attachment wp-att-395" href="http://veechand.wordpress.com/2009/08/22/5-little-known-snmp-secrets-of-the-experts/figure4/"><img class="size-full wp-image-395" title="Figure 4 - Using SNMP v2c" src="http://veechand.files.wordpress.com/2009/08/figure4.jpg?w=467&#038;h=87" alt="Figure 4 - Using SNMP v2c" width="467" height="87" /></a></dt>
<dd class="wp-caption-dd">Figure 4 &#8211; Using SNMP v2c</dd>
</dl>
</div>
<p>In case of SNMP version 1 Error Status and Error Index value will be updated properly*. However in SNMP version 2c these values are always set to zero (0) in response even in case of errors. So any assumption made in manager (NMS/EMS) based on these values will end up wrongly.</p>
<p><strong>*Note:</strong></p>
<ol>
<li>Error Status will indicate the type of error and Error Index will indicate the first varbinds that caused this error. (applicable only to SNMP v1)</li>
<li><a href="http://en.wikipedia.org/wiki/Network_management_system" target="_blank">NMS &#8211; Network Management System</a></li>
<li><a href="http://en.wikipedia.org/wiki/Element_management_system" target="_blank">EMS &#8211; Element Management System</a></li>
</ol>
<h2>5. ifIndex re-usage is agent specific</h2>
<p>IfTable is used to get the details about interfaces. This table is indexed using ifIndex, a unique index assigned to each interfaces. Reusing the ifIndex on swapping/removing of an interface is specific to agent implementation. For example, when user replaces an interface gi1/1 having ifIndex 10 with other interface say TenGig1/1, the new interface TenGig1/1 is not guaranteed to use the same ifIndex, 10.</p>
<p>Thanks to <a href="http://twitter.com/surendrakumar" target="_blank">@surendrakumar</a> for confirming TIP 5</p>
<p class="getsocial" style="text-align:left;"><a title="Add to Facebook" href="http://www.facebook.com/sharer.php?u=http://veechand.wordpress.com/2009/08/22/" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4013.png" alt="Add to Facebook" /></a><a title="Add to Newsvine" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F08%2F22%2F&amp;h=5%20Little%20known%20SNMP%20secrets%20of%20the%20experts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4023.png" alt="Add to Newsvine" /></a><a title="Add to Digg" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F08%2F22%2F&amp;title=5%20Little%20known%20SNMP%20secrets%20of%20the%20experts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4033.png" alt="Add to Digg" /></a><a title="Add to Del.icio.us" href="http://del.icio.us/post?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F08%2F22%2F&amp;title=5%20Little%20known%20SNMP%20secrets%20of%20the%20experts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4043.png" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F08%2F22%2F&amp;title=5%20Little%20known%20SNMP%20secrets%20of%20the%20experts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4053.png" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" href="http://reddit.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F08%2F22%2F&amp;title=5%20Little%20known%20SNMP%20secrets%20of%20the%20experts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4063.png" alt="Add to Reddit" /></a><a title="Add to Blinklist" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F08%2F22%2F&amp;Title=5%20Little%20known%20SNMP%20secrets%20of%20the%20experts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4073.png" alt="Add to Blinklist" /></a><a title="Add to Twitter" href="http://twitter.com/home/?status=5%20Little%20known%20SNMP%20secrets%20of%20the%20experts+%40+http%3A%2F%2Fveechand.wordpress.com%2F2009%2F08%2F22%2F" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4083.png" alt="Add to Twitter" /></a><a title="Add to Technorati" href="http://www.technorati.com/faves?add=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F08%2F22%2F" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4093.png" alt="Add to Technorati" /></a><a title="Add to Furl" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F08%2F22%2F&amp;t=5%20Little%20known%20SNMP%20secrets%20of%20the%20experts" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4103.png" alt="Add to Furl" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veechand.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veechand.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veechand.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veechand.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veechand.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veechand.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veechand.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veechand.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veechand.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veechand.wordpress.com/378/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=378&subd=veechand&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://veechand.wordpress.com/2009/08/22/5-little-known-snmp-secrets-of-the-experts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86b7deee7b6c29ee12158ba3455022e0?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">veeru</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/08/figure11.jpg" medium="image">
			<media:title type="html">Figure 1 - GetNext</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/08/figure2.jpg" medium="image">
			<media:title type="html">Figure 2 - Tabular (vs) scalar instances</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/08/figure3.jpg" medium="image">
			<media:title type="html">Figure 3 - Using SNMP V1</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/08/figure4.jpg" medium="image">
			<media:title type="html">Figure 4 - Using SNMP v2c</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4013.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4023.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4033.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4043.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4053.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4063.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4073.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4083.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4093.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4103.png" medium="image">
			<media:title type="html">Add to Furl</media:title>
		</media:content>
	</item>
		<item>
		<title>Your purpose of using twitter</title>
		<link>http://veechand.wordpress.com/2009/07/17/your-purpose-of-using-twitter/</link>
		<comments>http://veechand.wordpress.com/2009/07/17/your-purpose-of-using-twitter/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 05:34:28 +0000</pubDate>
		<dc:creator>Veerabahu</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[polls]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://veechand.wordpress.com/?p=367</guid>
		<description><![CDATA[poll twitter<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=367&subd=veechand&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><a name="pd_a_1790006"></a><div class="PDS_Poll" id="PDI_container1790006" style="display:inline-block;"></div><script type="text/javascript" language="javascript" charset="utf-8" src="http://static.polldaddy.com/p/1790006.js"></script>
		<noscript>
		<a href="http://answers.polldaddy.com/poll/1790006/">View This Poll</a><br/><span style="font-size:10px;"><a href="http://answers.polldaddy.com">polls</a></span>
		</noscript>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veechand.wordpress.com/367/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veechand.wordpress.com/367/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veechand.wordpress.com/367/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veechand.wordpress.com/367/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veechand.wordpress.com/367/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veechand.wordpress.com/367/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veechand.wordpress.com/367/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veechand.wordpress.com/367/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veechand.wordpress.com/367/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veechand.wordpress.com/367/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=367&subd=veechand&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://veechand.wordpress.com/2009/07/17/your-purpose-of-using-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86b7deee7b6c29ee12158ba3455022e0?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">veeru</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding buttons to JQGrid toolbar</title>
		<link>http://veechand.wordpress.com/2009/07/14/adding-buttons-to-jqgrid-toolbar/</link>
		<comments>http://veechand.wordpress.com/2009/07/14/adding-buttons-to-jqgrid-toolbar/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 06:23:41 +0000</pubDate>
		<dc:creator>Veerabahu</dc:creator>
				<category><![CDATA[techinal]]></category>
		<category><![CDATA[jqgrid]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[js]]></category>

		<guid isPermaLink="false">http://veechand.wordpress.com/?p=314</guid>
		<description><![CDATA[Adding buttons to JQGRID toolbars<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=314&subd=veechand&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>As I have wrote in my previous <a href="http://veechand.wordpress.com/2009/07/13/10-jqgrid-tips-learned-from-my-experience/" target="_blank">article</a>, JQGrid is one of the most powerful JQuery      plug-ins used in creation of grids. Though JQGrid provides most of the functionality out of box, there are certain things for which we might need to extend. I came across one such requirement a week before.</p>
<p><span id="more-314"></span></p>
<p>JQGrid add buttons, like search to the navigator (pager) component. This navigator component is placed below the table. As far as user experience (UE) is considered action items needs to be placed at the top of the grid for easier accessibility (and many other reasons,  which I am not much aware of, comment if you are). So I started to dig in to JQGrid documents and source to achieve this. During this time, <a href="http://twitter.com/rameenak">Rama</a> pointed me about the toolbar option.  But there is no API in JQGrid to add buttons with the same look and feel as navigator buttons in toolbar (readers comment if you find any). This gave me a chance to extend JQGrid plug-in for this functionality.  With sometime over the weekend, I am able to achieve the same. Here, I share the code with you</p>
<pre><strong>Note: Updated code at end of post</strong>
<pre class="brush: jscript;">
/*
 * Add functionality to add buttons to toolbar instead of pager
 * Why can't we use the navButtonAdd method by passing toolbar as the element
 * 	1. By default toolbar:[true,&quot;both/top/bottom&quot;] adds a div perfectly between the table caption and header. But there is not table within this div. Due to this structure difference we can't make use of navButtonAdd
 *      2. We can go ahead by appending table inside toolbar div and then reusing navButtonAdd. But that still needs some more customziation. So went ahead with a new method
 */
$.fn.extend({
/*
 *
 * The toolbar has the following properties
 *	id of top toolbar: t_
&lt;tablename&gt;
 *	id of bottom toolbar: tb_
&lt;tablename&gt;
 *	class of toolbar: ui-userdata
 * elem is the toolbar name to which button needs to be added. This can be
 *	#t_tablename - if button needs to be added to the top toolbar
 *	#tb_tablename - if button needs to be added to the bottom toolbar
 */
    toolbarButtonAdd: function(elem,p){
       p = $.extend({
                caption : &quot;newButton&quot;,
                title: '',
                buttonicon : 'ui-icon-newwin',
                onClickButton: null,
                position : &quot;last&quot;
              }, p ||{});
        var $elem = $(elem);
 	var tableString=&quot;
&lt;table cellspacing=\&quot;0\&quot; cellpadding=\&quot;0\&quot; border=\&quot;0\&quot; style=\&quot;table-layout: fixed;\&quot;&gt;&quot;;
	tableString+=&quot;
&lt;tbody&gt;
&lt;tr&gt;&lt;/tr&gt;
&lt;/table&gt;
&quot;;

      /*
	* Step 1: check whether a table is already added. If not add
	* Step 2: If there is no table already added then add a table
	* Step 3: Make the element ready for addition to the table
	* Step 4: Check the position and corresponding add the element
	* Step 5: Add other properties
	*/
        return this.each(function() {
		if( !this.grid)  { return; }
		if(elem.indexOf(&quot;#&quot;) != 0) {
			elem = &quot;#&quot;+elem;
		}
		//step 2
		if($(elem).children('table').length === 0){
			$(elem).append(tableString);
		}
		//step 3
		var tbd = $(&quot;
&lt;td&gt;&lt;/td&gt;
&quot;);
		$(tbd).addClass('ui-pg-button ui-corner-all').append(&quot;
&lt;div class='ui-pg-div'&gt;&lt;span class='ui-icon &quot;+p.buttonicon+&quot;'&gt;&lt;/span&gt;&quot;+p.caption+&quot;&lt;/div&gt;
&quot;).attr(&quot;title&quot;,p.title  || &quot;&quot;)
	    .click(function(e){
		if ($.isFunction(p.onClickButton) ) {  p.onClickButton(); }
		return false;
		})
             .hover(
		function () {$(this).addClass(&quot;ui-state-hover&quot;);},
		function () {$(this).removeClass(&quot;ui-state-hover&quot;);}
		);
		if(p.id) {$(tbd).attr(&quot;id&quot;,p.id);}
		if(p.align) {$(elem).attr(&quot;align&quot;,p.align);}
		var findnav=$(elem).children('table');
		if(p.position ==='first'){
			if($(findnav).find('td').length === 0 ) {
				$(&quot;tr&quot;,findnav).append(tbd);
			} else {
				$(&quot;tr td:eq(0)&quot;,findnav).before(tbd);
			}
		} else {
			$(&quot;tr&quot;,findnav).append(tbd);
		        }
	});//this.each()
     }
});
</pre>
<p> <span style="font-family:Georgia;line-height:19px;white-space:normal;font-size:13px;">I hope there is no rocket science in the above code, so I am not explaining it here. The toolbarButtonAdd function will be more or less the same as navButtonAdd function in grid.formedit.js. One extra option that I have introduced is <strong>align</strong>. I have introduced this option to align the button in toolbar based on user preference. Align could take left, right, center.  I hope, MAC users will be more comfortable with buttons in left and Windows/nix users are comfortable with toolbars in right.</span> <strong>Note:</strong> The element should point to the toolbar div. The id of the toolbar   div depends upon the position as follows,</p>
<ol>Top toolbar: t_&lt;tableid&gt;</ol>
<p>Bottom toolbar: tb_&lt;tableid&gt;   <strong>Sample Usage:</strong>
<pre class="brush: jscript;">
$('#mysimpletable')
.toolbarButtonAdd(&quot;#t_mysimpletable&quot;,{caption:&quot;Toggle&quot;,position:&quot;first&quot;,
title:&quot;Toggle Search Toolbar&quot;, align:&quot;right&quot;, buttonicon :'ui-icon-search', onClickButton:function(){ mygrid[0].toggleToolbar(); } })
</pre>
<p> Let me know your comments on the above piece of <strong>toolbarButtonAdd </strong>function.<br />
 Now, I am working on unit-testing and code coverage tools for JS.  So you could soon expect a blog on the same.<br />
Update 24-jul-2009 - New code is available at<br />
Updated 13-Aug-2009 - Support for IE <a href="http://snippets.dzone.com/posts/show/7629">http://snippets.dzone.com/posts/show/7629</a><br />
<a title="Add to Facebook" href="http://www.facebook.com/sharer.php?u=http://veechand.wordpress.com/2009/07/14/" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4012.png" alt="Add to Facebook" /></a><a title="Add to Newsvine" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F14%2F&amp;h=Adding%20buttons%20to%20JQGrid%20toolbar" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4022.png" alt="Add to Newsvine" /></a><a title="Add to Digg" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F14%2F&amp;title=Adding%20buttons%20to%20JQGrid%20toolbar" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4032.png" alt="Add to Digg" /></a><a title="Add to Del.icio.us" href="http://del.icio.us/post?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F14%2F&amp;title=Adding%20buttons%20to%20JQGrid%20toolbar" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4042.png" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F14%2F&amp;title=Adding%20buttons%20to%20JQGrid%20toolbar" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4052.png" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" href="http://reddit.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F14%2F&amp;title=Adding%20buttons%20to%20JQGrid%20toolbar" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4062.png" alt="Add to Reddit" /></a><a title="Add to Blinklist" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F14%2F&amp;Title=Adding%20buttons%20to%20JQGrid%20toolbar" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4072.png" alt="Add to Blinklist" /></a><a title="Add to Twitter" href="http://twitter.com/home/?status=Adding%20buttons%20to%20JQGrid%20toolbar+%40+http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F14%2F" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4082.png" alt="Add to Twitter" /></a><a title="Add to Technorati" href="http://www.technorati.com/faves?add=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F14%2F" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4092.png" alt="Add to Technorati" /></a><a title="Add to Furl" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F14%2F&amp;t=Adding%20buttons%20to%20JQGrid%20toolbar" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4102.png" alt="Add to Furl" /></a></pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veechand.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veechand.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veechand.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veechand.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veechand.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veechand.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veechand.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veechand.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veechand.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veechand.wordpress.com/314/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=314&subd=veechand&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://veechand.wordpress.com/2009/07/14/adding-buttons-to-jqgrid-toolbar/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86b7deee7b6c29ee12158ba3455022e0?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">veeru</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4012.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4022.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4032.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4042.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4052.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4062.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4072.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4082.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4092.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4102.png" medium="image">
			<media:title type="html">Add to Furl</media:title>
		</media:content>
	</item>
		<item>
		<title>10 JQGrid Tips learned from my experience</title>
		<link>http://veechand.wordpress.com/2009/07/13/10-jqgrid-tips-learned-from-my-experience/</link>
		<comments>http://veechand.wordpress.com/2009/07/13/10-jqgrid-tips-learned-from-my-experience/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 06:58:53 +0000</pubDate>
		<dc:creator>Veerabahu</dc:creator>
				<category><![CDATA[techinal]]></category>
		<category><![CDATA[jqgrid]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[js]]></category>

		<guid isPermaLink="false">http://veechand.wordpress.com/?p=246</guid>
		<description><![CDATA[ For the past few days I have been working with JQGrid, one of the most powerful JQuery plug-in.  To give an outline, JQGrid helps us to create a grid with ease. The power of JQGrid comes from the fact that almost all the needs for a grid are addressed using simple tunable options. JQGrid [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=246&subd=veechand&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong> </strong>For the past few days I have been working with JQGrid, one of the most powerful JQuery plug-in.  To give an outline, JQGrid helps us to create a grid with ease. The power of JQGrid comes from the fact that almost all the needs for a grid are addressed using simple tunable options. JQGrid can be downloaded from <a href="http://www.trirand.com/blog/?page_id=6">http://www.trirand.com/blog/?page_id=6</a>.  JQGrid has a good documentation available at <a href="http://www.secondpersonplural.ca/jqgriddocs/index.htm">http://www.secondpersonplural.ca/jqgriddocs/index.htm</a>. Also most of the JQGrid options are demonstrated well in <a href="http://www.trirand.com/jqgrid35/jqgrid.html">http://www.trirand.com/jqgrid35/jqgrid.html</a>. In spite of these well written documents, there are times I spent digging JQGrid source code for some customization needs. I also strongly feel that most of my co-workers might need the same at some point of time, so thought of blogging (documenting) for further reference.</p>
<p><span id="more-246"></span></p>
<p>All the code used in this article can be downloaded from <a href="http://veechand.files.wordpress.com/2009/07/grid.doc" target="_blank">here</a>.</p>
<p>Our very first table looks as below<img class="alignright size-full wp-image-251" title="draft-table" src="http://veechand.files.wordpress.com/2009/07/draft-table1.jpg?w=205&#038;h=288" alt="draft-table" width="205" height="288" /></p>
<p><strong>TIP 1: Changing JQGrid width and height</strong></p>
<p>As depicted in the picture, the table doesn’t show up with paging information. Due to the smaller width, the 2<sup>nd</sup> column header and value are also not fully visible.  To solve this, we need to set the width of the table, thereby columns. This can be achieved as shown below</p>
<ol>
<li>During grid creation, use the property width with value in pixel as</li>
</ol>
<p><span style="font-family:Consolas;line-height:18px;font-size:12px;white-space:pre;"> </span></p>
<pre class="brush: jscript;">
width:700
</pre>
<p>OR</p>
<p>2. After grid creation, use setGridWidth(width, shrink) API as</p>
<pre class="brush: jscript;">
$([tableid]).setGridWidth(700,true);
</pre>
<p>Similarly, height of the table can also be set using height :&lt;value is pixel&gt; and setGridHeight(height) API.  The default height is 150px. I am still searching for a way to set width/height of JQGrid in percentage (%). Comment, if you already know it.</p>
<p><strong>TIP 2: Grid without unnecessary scroll area</strong></p>
<p>If you are sure that the grid is not going to take more than N values and those N values can be fit in a single page, then there is no need for a scroll bar. In this case the space allotted for scrollbar is immaterial. I would rather prefer to remove this space. This can be achieved by setting the value of scrollOffset to zero as follows,</p>
<pre style="font:normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">
<pre class="brush: jscript;">
scrollOffset:0
</pre>
<p>By default the value of scrolloffset will be 18px</pre>
<p><strong>TIP 3:  Error due to missing locale file</strong></p>
<p>You have included all the needed JS files like, JQuery, jqgrid (single file as minimized js/jquery.jqGrid.min.js) but still hitting with an error “<strong><em>$.jgrid is undefined</em></strong>” and grid is not rendered. This might be due to missing locale file. To solve this include appropriate locale, as</p>
<pre class="brush: jscript;">
&lt;script src=&quot;jqgridsrc/src/i18n/grid.locale-en.js&quot; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
</pre>
<p><strong>TIP 4: Callback function</strong></p>
<p>We came across a requirement where we need to associate a hover event only to the first cell of a grid. To do the same, we need to get the first cell (td) and associate hover function on it and then implementing the functionality needed. Let’s assume that these functionalities (writing selector to get the first cell and writing .hover(…) function) is available in a function named doWhenHover(). The point here is when to call this function? THINK !! THINK !! THINK !!</p>
<p>If you told that it should be after the function that creates the table, in our example createMyTable(), then you are wrong.  Since the grid is not guaranteed to be completely formed at the end of createMyTable() function. So, JQGrid provides a callback function, <strong><em>loadComplete</em></strong> to which a function can be associated during grid creation like,</p>
<pre class="brush: jscript;">

loadComplete: doWhenGridFullyLoaded

….

//grid creation completed

function doWhenGridFullyLoaded(){

//do the operation here

}
</pre>
<p><strong>TIP 5: Using pagers only for buttons (or icons)</strong></p>
<p>JQGrid documentation provides a tip at <a href="http://www.secondpersonplural.ca/jqgriddocs/index.htm">http://www.secondpersonplural.ca/jqgriddocs/index.htm</a> under jqGrid &gt; User Modules &gt; Tips, Tricks and Hacks using which pager can be removed.  Here is yet another way to do the same. If you want to have pager only to add buttons and don’t like to display page numbers and other stuffs then we could remove those items as shown below,</p>
<pre class="brush: jscript;">

$(‘#
&lt;pagername&gt;_center’).remove();

$(‘#
&lt;pagername&gt;_right’).remove();

Example: $('#mysimpletablepager_right').remove();
</pre>
<p><strong>TIP 6: Hiding unwanted buttons in navigation bar</strong></p>
<p>When navGrid(…) API is called to add a icon, say refresh  as</p>
<pre class="brush: jscript;">

$(‘#
&lt;tableid&gt;’).navGrid('#mysimpletablepager',{refresh:true});
</pre>
<p>the following icons will be added in addition to the refresh icon</p>
<p>edit, add, del, refresh, search</p>
<p>To hide any of these icons associate those icons to a value of false. Say for example to hide edit, add icons and show other icons we can use the following fragment of code</p>
<pre class="brush: jscript;">

$(‘#
&lt;tableid&gt;’).navGrid('#mysimpletablepager',{edit:false,add:false});
</pre>
<p>Also, by default view icon will be hidden, this can be made visible by associating true to it as <strong><em>view:true</em></strong></p>
<p><strong>Tip 7: Hiding the inline search by default</strong></p>
<p>In addition to the popup search in JQGrid there is also an additional option of having inline search. In this case, a search textbox will be added to top of each column. Refer JQGrid documentation for the procedure to add inline search. But, when we add inline search functionality the search textbox will be shown by default and it occupies the first row below the header.  Though it can be argued that, showing search textbox by default makes the functionality explicit to user, I like it to be the other way i.e. when the grid is loaded the search textbox has to be hidden. User can make explicit request to show the search textbox. To do the same call <strong><em>mygrid[0].toggleToolbar()</em></strong> (the same code that is called when inline search icon is clicked) at the end of grid creation code as follows,</p>
<pre class="brush: jscript;">

var myGrid = $(‘#mysimpletable’).jqGrid({

     url:&lt;value&gt;,

    ….//.other options

   })

.navButtonAdd(&quot;&lt;
&lt;pagerid&gt;&gt;&quot;,{caption:&quot;&quot;,title:&quot;Toggle Search Toolbar&quot;, buttonicon :'ui-icon-search', onClickButton:function(){ mygrid[0].toggleToolbar() } }); //icon to add the search bar with search textbox

mygrid.filterToolbar(); //adds the search toolbar

mygrid[0].toggleToolbar();//hide the toolbar by default
</pre>
<p><strong>TIP 8: Having your own icons for navigation bar buttons</strong></p>
<p>We are not always fulfilled with the available JQGrid/JQuery-UI images. So we might need to put our own image/icon for some of the buttons. This could be achieved by writing our own CSS and associating it with the navigator grid button by specifying it as a value to buttonicon as shown below</p>
<pre class="brush: css;">

.ui-icon.myicon {

    width: 16px;

    height: 16px;

    background-image:url(edit.png);

}
</pre>
<pre class="brush: jscript;">

mygrid.navButtonAdd(&quot;#mysimpletablepager&quot;,{caption:&quot;&quot;,title:&quot;Toggle Search Toolbar&quot;, buttonicon:'myicon', onClickButton:function(){ mygrid[0].toggleToolbar() } });
</pre>
<p><strong>TIP 9: Removing title bar close button</strong></p>
<p>I don’t find a real use of the tile bar close button. It would be much useful if the adjacent components occupy the space whenever user shrinks the grid, something like IGoogle portlets. Though JQGrid does it, it largely depends on the enclosing component. So I prefer to remove of button thereby hiding the functionality from user. As other removal this can also be easily achieved using remove() API as shown below</p>
<pre class="brush: jscript;">

$('.ui-jqgrid-titlebar-close','#gview_mysimpletable').remove();
</pre>
<p>Note: Title bar won’t appear if the caption is an empty string.</p>
<p><strong>TIP 10: Adding toolbar</strong></p>
<p>JQGrid also provides an option to add toolbar to the table. This can be achieved using toolbar option, toolbar:[true,"both"] during grid creation. First parameter specifies whether the grid needs to be added or not. The second parameter is to tell about the location of the toolbar. Second parameter can take three values namely, top, bottom and both.</p>
<p>Stay tuned to know about the procedure for adding buttons to toolbar.</p>
<p><strong>Version of</strong></p>
<p>JQGrid &#8211; 3.5 beta</p>
<p>JQuery &#8211; 1.3.2</p>
<p>JQuery UI Theme &#8211; Dark Hive</p>
<p>Feel free to share your experience with JQGrid and also if you have cleaner way to solve some of the items discussed above, as comments.</p>
<p><a title="Add to Facebook" href="http://www.facebook.com/sharer.php?u=http://veechand.wordpress.com/2009/07/13/" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4012.png" alt="Add to Facebook" /></a><a title="Add to Newsvine" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F13%2F&amp;h=10%20JQGrid%20Tips%20learned%20from%20my%20experience" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4022.png" alt="Add to Newsvine" /></a><a title="Add to Digg" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F13%2F&amp;title=10%20JQGrid%20Tips%20learned%20from%20my%20experience" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4032.png" alt="Add to Digg" /></a><a title="Add to Del.icio.us" href="http://del.icio.us/post?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F13%2F&amp;title=10%20JQGrid%20Tips%20learned%20from%20my%20experience" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4042.png" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F13%2F&amp;title=10%20JQGrid%20Tips%20learned%20from%20my%20experience" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4052.png" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" href="http://reddit.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F13%2F&amp;title=10%20JQGrid%20Tips%20learned%20from%20my%20experience" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4062.png" alt="Add to Reddit" /></a><a title="Add to Blinklist" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F13%2F&amp;Title=10%20JQGrid%20Tips%20learned%20from%20my%20experience" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4072.png" alt="Add to Blinklist" /></a><a title="Add to Twitter" href="http://twitter.com/home/?status=10%20JQGrid%20Tips%20learned%20from%20my%20experience+%40+http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F13%2F" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4082.png" alt="Add to Twitter" /></a><a title="Add to Technorati" href="http://www.technorati.com/faves?add=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F13%2F" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4092.png" alt="Add to Technorati" /></a><a title="Add to Furl" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F07%2F13%2F&amp;t=10%20JQGrid%20Tips%20learned%20from%20my%20experience" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4102.png" alt="Add to Furl" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veechand.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veechand.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veechand.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veechand.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veechand.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veechand.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veechand.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veechand.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veechand.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veechand.wordpress.com/246/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=246&subd=veechand&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://veechand.wordpress.com/2009/07/13/10-jqgrid-tips-learned-from-my-experience/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86b7deee7b6c29ee12158ba3455022e0?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">veeru</media:title>
		</media:content>

		<media:content url="http://veechand.files.wordpress.com/2009/07/draft-table1.jpg" medium="image">
			<media:title type="html">draft-table</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4012.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4022.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4032.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4042.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4052.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4062.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4072.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4082.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4092.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4102.png" medium="image">
			<media:title type="html">Add to Furl</media:title>
		</media:content>
	</item>
		<item>
		<title>JQuery Tip &#8211; 3: Custom JQuery Selector</title>
		<link>http://veechand.wordpress.com/2009/05/25/customselector/</link>
		<comments>http://veechand.wordpress.com/2009/05/25/customselector/#comments</comments>
		<pubDate>Mon, 25 May 2009 04:39:12 +0000</pubDate>
		<dc:creator>Veerabahu</dc:creator>
				<category><![CDATA[techinal]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[js]]></category>

		<guid isPermaLink="false">http://veechand.wordpress.com/?p=226</guid>
		<description><![CDATA[jquery selectors<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=226&subd=veechand&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>       Though JQuery comes with a bunch of selectors, there are situation where we need to have additional functionality. JQuery has provided the interface using which we could harness our selector with the already available selectors. In this blog we are going to see 4 easy steps to do the same.<span id="more-226"></span><br />
<strong> Step 1:</strong></p>
<p>  Write your HTML file, include JQuery script and decide on the name of selector (important one <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> )</p>
<p><strong> Step 2:</strong></p>
<p><strong><span style="font-weight:normal;"> Extend the ‘:’ selector using JQuery extend function as follows,</span></strong></p>
<pre class="brush: jscript;">
  $.extend($.expr[':'],{
    selectorname&gt;:function( elem, index, match, array ){
    }
  });
</pre>
<p><strong>Step 3:</strong></p>
<p>     For each element our method will be called by JQuery,  passing the element (note this is not JQuery element). If the element satisfies the condition return true, if not return false. JQuery will add the element to the resulting array if the function returns true.<br />
<strong>Step 4:</strong><br />
                Use It and Test It</p>
<p>This is my first blog with screen cast.<br />
<script type='text/javascript' src='http://blip.tv/syndication/write_player?skin=js&#038;posts_id=2161970&#038;cross_post_destination=-1&#038;view=full_js'></script><br />
Have easy learning, and let me know your comments on it.  The code that we developed in our screen cast is below, </p>
<pre class="brush: jscript;">
  &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot;&gt;
    &lt;head&gt;
        &lt;title&gt;Custom Jquery Selector Demo&lt;/title&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.3.js&quot;&gt;&lt;/script&gt;
        &lt;script&gt;
         &lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;/*
           * Demonstrating Custom Selector
           * Objectives
           * Select all elements whose value for mySpecialAttr is greater than 9
           */
          $.extend($.expr[':'],{
              mySpecialAttrValueGreaterThan9: function( elem, index, match, array ){
                 var $element = $(elem);
                 var specialAttrValue = $element.attr('mySpecialAttr');
                 console.log(&quot;specialAttrValue=&quot;+specialAttrValue);
                 if(specialAttrValue != null &amp;&amp; specialAttrValue.length &gt; 9){
                      return true;
                 }
                 return false;
              }
           });
          $(document).ready(function() {
              console.log(&quot;Ready function getting executed&quot;);
              var $mySpeciaAttr = $(':mySpecialAttrValueGreaterThan9');
              $('#results').html(&quot;myspecialattribute result=&lt;b&gt;&quot;+$mySpeciaAttr.size()+&quot;&lt;b&gt;&quot;);
          });
        &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
     &lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;&quot; /&gt;
     &lt;input type=&quot;text&quot; name=&quot;Age&quot; value=&quot;&quot; mySpecialAttr=&quot;Small&quot;/&gt;
     &lt;input type=&quot;text&quot; name=&quot;Address&quot; value=&quot;&quot; myspecialAttr=&quot;Length greater than nine&quot;/&gt;
     &lt;input type=&quot;text&quot; name=&quot;Address&quot; value=&quot;&quot; myspecialAttr=&quot;Length greater than and second&quot;/&gt;
     &lt;span class=&quot;test&quot; id=&quot;results&quot;&gt;&lt;/span&gt;
    &lt;/body&gt;
   &lt;/html&gt;
</pre>
<p class="getsocial" style="text-align:left;"><a title="Add to Facebook" href="http://www.facebook.com/sharer.php?u=http://veechand.wordpress.com/2009/05/24/customselector" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4013.png" alt="Add to Facebook" /></a><a title="Add to Newsvine" href="http://www.newsvine.com/_wine/save?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F05%2F24%2Fcustomselector&amp;h=JQuery%20Tip%20-%203%3A%20Custom%20JQuery%20Selector" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4023.png" alt="Add to Newsvine" /></a><a title="Add to Digg" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F05%2F24%2Fcustomselector&amp;title=JQuery%20Tip%20-%203%3A%20Custom%20JQuery%20Selector" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4033.png" alt="Add to Digg" /></a><a title="Add to Del.icio.us" href="http://del.icio.us/post?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F05%2F24%2Fcustomselector&amp;title=JQuery%20Tip%20-%203%3A%20Custom%20JQuery%20Selector" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4043.png" alt="Add to Del.icio.us" /></a><a title="Add to Stumbleupon" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F05%2F24%2Fcustomselector&amp;title=JQuery%20Tip%20-%203%3A%20Custom%20JQuery%20Selector" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4053.png" alt="Add to Stumbleupon" /></a><a title="Add to Reddit" href="http://reddit.com/submit?url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F05%2F24%2Fcustomselector&amp;title=JQuery%20Tip%20-%203%3A%20Custom%20JQuery%20Selector" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4063.png" alt="Add to Reddit" /></a><a title="Add to Blinklist" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F05%2F24%2Fcustomselector&amp;Title=JQuery%20Tip%20-%203%3A%20Custom%20JQuery%20Selector" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4073.png" alt="Add to Blinklist" /></a><a title="Add to Twitter" href="http://twitter.com/home/?status=JQuery%20Tip%20-%203%3A%20Custom%20JQuery%20Selector+%40+http%3A%2F%2Fveechand.wordpress.com%2F2009%2F05%2F24%2Fcustomselector" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4083.png" alt="Add to Twitter" /></a><a title="Add to Technorati" href="http://www.technorati.com/faves?add=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F05%2F24%2Fcustomselector" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4093.png" alt="Add to Technorati" /></a><a title="Add to Furl" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fveechand.wordpress.com%2F2009%2F05%2F24%2Fcustomselector&amp;t=JQuery%20Tip%20-%203%3A%20Custom%20JQuery%20Selector" target="_blank"><img style="border:0;margin:0;padding:0;" src="http://getsocialserver.files.wordpress.com/2009/02/gs4103.png" alt="Add to Furl" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veechand.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veechand.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veechand.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veechand.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veechand.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veechand.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veechand.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veechand.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veechand.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veechand.wordpress.com/226/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=veechand.wordpress.com&blog=4898249&post=226&subd=veechand&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://veechand.wordpress.com/2009/05/25/customselector/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86b7deee7b6c29ee12158ba3455022e0?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">veeru</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4013.png" medium="image">
			<media:title type="html">Add to Facebook</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4023.png" medium="image">
			<media:title type="html">Add to Newsvine</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4033.png" medium="image">
			<media:title type="html">Add to Digg</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4043.png" medium="image">
			<media:title type="html">Add to Del.icio.us</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4053.png" medium="image">
			<media:title type="html">Add to Stumbleupon</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4063.png" medium="image">
			<media:title type="html">Add to Reddit</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4073.png" medium="image">
			<media:title type="html">Add to Blinklist</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4083.png" medium="image">
			<media:title type="html">Add to Twitter</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4093.png" medium="image">
			<media:title type="html">Add to Technorati</media:title>
		</media:content>

		<media:content url="http://getsocialserver.files.wordpress.com/2009/02/gs4103.png" medium="image">
			<media:title type="html">Add to Furl</media:title>
		</media:content>
	</item>
	</channel>
</rss>