<?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>Senthamil Bharathi's Weblog</title>
	<atom:link href="http://sssbharathi.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://sssbharathi.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Thu, 29 May 2008 06:32:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='sssbharathi.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Senthamil Bharathi's Weblog</title>
		<link>http://sssbharathi.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://sssbharathi.wordpress.com/osd.xml" title="Senthamil Bharathi&#039;s Weblog" />
	<atom:link rel='hub' href='http://sssbharathi.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Thread-safe Servlets</title>
		<link>http://sssbharathi.wordpress.com/2008/05/29/thread-safe-servlets/</link>
		<comments>http://sssbharathi.wordpress.com/2008/05/29/thread-safe-servlets/#comments</comments>
		<pubDate>Thu, 29 May 2008 06:32:34 +0000</pubDate>
		<dc:creator>sssbharathi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sssbharathi.wordpress.com/2008/05/29/thread-safe-servlets/</guid>
		<description><![CDATA[Identify which attribute scopes are thread-safe: Local variables Yes, thread-safe Instance variables Not thread-safe Since a single servlet instance may be handling multiple service requests at any given time. Class variables Not thread-safe Since multiple servlets and /or service requests may try to access a class variable concurrently. Request attributes Not thread-safe See the quote [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sssbharathi.wordpress.com&amp;blog=3748082&amp;post=8&amp;subd=sssbharathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a name="#top"><font color="red">Identify which attribute scopes are thread-safe: </font></a>
<ol><a name="#top"><font color="red">
<li>Local variables </font> Yes, thread-safe <font color="red">
<li>Instance variables </font> Not thread-safe<br /> Since a single servlet instance may be handling multiple service requests at any given time. <font color="red">
<li>Class variables </font> Not thread-safe<br /> Since  multiple servlets and /or service requests may try to access a class variable concurrently. <font color="red">
<li>Request attributes </font> Not thread-safe<br /> See </a><a href="http://www.javacamp.org/scwcd/course/7_1.html#threadsafe">the quote </a>below. <font color="red">
<li>Session attributes </font> Not thread-safe<br /> Since sessions are scoped at the web application level, hence the same session object  can be accessed concurrently by multiple servlets and their service requests  <font color="red">
<li>Context attributes </font> Not thread-safe<br /> Since the same context object can be accessed concurrently by multiple servlets  and their service requests </ol>
<p></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sssbharathi.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sssbharathi.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sssbharathi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sssbharathi.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sssbharathi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sssbharathi.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sssbharathi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sssbharathi.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sssbharathi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sssbharathi.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sssbharathi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sssbharathi.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sssbharathi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sssbharathi.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sssbharathi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sssbharathi.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sssbharathi.wordpress.com&amp;blog=3748082&amp;post=8&amp;subd=sssbharathi&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://sssbharathi.wordpress.com/2008/05/29/thread-safe-servlets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/760fbb9669281633d0dce00548cee740?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sssbharathi</media:title>
		</media:content>
	</item>
		<item>
		<title>Struts Action Class singleton</title>
		<link>http://sssbharathi.wordpress.com/2008/05/29/struts-action-class-singleton/</link>
		<comments>http://sssbharathi.wordpress.com/2008/05/29/struts-action-class-singleton/#comments</comments>
		<pubDate>Thu, 29 May 2008 05:52:46 +0000</pubDate>
		<dc:creator>sssbharathi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sssbharathi.wordpress.com/2008/05/29/struts-action-class-singleton/</guid>
		<description><![CDATA[Struts (singleton)and the&#160;merger Struts and WebWorks Frameworks are merging. The Struts message board details this. Could it be that these are some reasons for merger? Now , back from the commercial break. The Action classes are singleton classes that are instantiated once per class type per JVM, and all requests for a specific action are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sssbharathi.wordpress.com&amp;blog=3748082&amp;post=7&amp;subd=sssbharathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2><a href="http://technobuzz.wordpress.com/2005/11/29/struts-singletonand-the-merger/" title="Permalink">Struts (singleton)and the&nbsp;merger</a></h2>
<p>Struts and WebWorks Frameworks are <a href="http://blog.f12.no/wp/2005/11/29/java-consolidation">merging</a>. The Struts <a href="http://marc.theaimsgroup.com/?t=113292413000005&amp;r=1&amp;w=2">message board details</a> this.</p>
<p>Could it be that these are <a href="http://www.javapractices.com/Topic193.cjp">some reasons</a> for merger?</p>
<p>Now , back from the commercial break.</p>
<p>The Action classes are singleton classes that are instantiated once per class type per JVM, and all requests for a specific action are routed through&nbsp; the same Action class instance. This <a href="http://www-128.ibm.com/developerworks/java/library/wa-rubyonrails/">IBM article</a> states this well: </p>
<p>&quot;Struts will create a single instance of the <span style="font-size:0.8em;">Action</span> and allow multiple threads to invoke <span style="font-size:0.8em;">execute()</span>. This allows for faster request processing, as the framework is not continually creating new <span style="font-size:0.8em;">Action</span> instances to handle each request. But because a single object is shared between multiple threads, you must observe proper threading considerations, as other threads are likely to pummel instance variables that hold state in the action. &quot;</p>
<p>The <a href="http://www.javacamp.org/scwcd/course/7_1.html">thread safety</a> thing always seems to comes into play. Now to the Struts Action Class <a href="http://struts.apache.org/struts-action/userGuide/building_controller.html">Guidelines</a>:</p>
<p>&quot; <strong>Write code for a multi-threaded environment</strong> &#8211; Our controller servlet creates <strong>only one instance of your Action class</strong>, and uses this one instance to service all requests. Thus, you need to write thread-safe Action classes. Follow the same guidelines you would use to write thread-safe Servlets. Here are two general guidelines that will help you write scalable, thread-safe Action classes: </p>
<p><strong>Only Use Local Variables</strong> &#8211; The most important principle that aids in thread-safe coding is to use only local variables, <strong>not instance variables</strong>, in your Action class. Local variables are created on a stack that is assigned (by your JVM) to each request thread, so there is no need to worry about sharing them. An Action can be factored into several local methods, so long as all variables needed are passed as method parameters. This assures thread safety, as the JVM handles such variables internally using the call stack which is associated with a single Thread. </p>
<p><strong>Conserve Resources</strong> &#8211; As a general rule, allocating scarce resources and keeping them across requests from the same user (in the user&rsquo;s session) can cause scalability problems. For example, if your application uses JDBC and you allocate a separate JDBC connection for every user, you are probably going to run in some scalability issues when your site suddenly shows up on Slashdot. You should strive to use pools and release resources (such as database connections) prior to forwarding control to the appropriate View component &mdash; even if a bean method you have called throws an exception. </p>
<p><strong>Don&rsquo;t throw it, catch it!</strong> &#8211; Ever used a commercial website only to have a stack trace or exception thrown in your face after you&rsquo;ve already typed in your credit card number and clicked the purchase button? Let&rsquo;s just say it doesn&rsquo;t inspire confidence. Now is your chance to deal with these application errors &#8211; in the Action class. If your application specific code throws expections you should catch these exceptions in your Action class, log them in your application&rsquo;s log (servlet.log(&quot;Error message&quot;, exception)) and return the appropriate ActionForward. </p>
<p>It is wise to avoid creating lengthy and complex Action classes. If you start to embed too much logic in the Action class itself, you will begin to find the Action class hard to understand, maintain, and impossible to reuse. Rather than creating overly complex Action classes, it is generally a good practice to move most of the persistence, and &quot;business logic&quot; to a separate application layer. When an Action class becomes lengthy and procedural, it may be a good time to refactor your application architecture and move some of this logic to another conceptual layer; otherwise, you may be left with an inflexible application which can only be accessed in a web-application environment. The framework should be viewed as simply the <strong>foundation</strong> for implementing MVC in your applications. Struts Action Framework provides a useful control layer, but it is not a fully featured platform for building MVC applications, soup to nuts. &quot;</p>
<p>Lastly, note <a href="http://www.springframework.org/node/185">that</a> :</p>
<p>&quot;actions are cached, they must be thread-safe. That does&rsquo;t mean that you can&rsquo;t use instance variables. If those instance variables are thread safe, and the objects they reference are thread-safe, then everything is good. Servlets suffer the same problem because Servlets are pooled by the container. By default Spring delivers singletons. As long as the services are thread-safe (as all singletons should be), there is no danger.&quot;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sssbharathi.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sssbharathi.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sssbharathi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sssbharathi.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sssbharathi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sssbharathi.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sssbharathi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sssbharathi.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sssbharathi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sssbharathi.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sssbharathi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sssbharathi.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sssbharathi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sssbharathi.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sssbharathi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sssbharathi.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sssbharathi.wordpress.com&amp;blog=3748082&amp;post=7&amp;subd=sssbharathi&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://sssbharathi.wordpress.com/2008/05/29/struts-action-class-singleton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/760fbb9669281633d0dce00548cee740?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sssbharathi</media:title>
		</media:content>
	</item>
		<item>
		<title>India is a land of billion opportunities</title>
		<link>http://sssbharathi.wordpress.com/2008/05/18/india-is-a-land-of-billion-opportunities/</link>
		<comments>http://sssbharathi.wordpress.com/2008/05/18/india-is-a-land-of-billion-opportunities/#comments</comments>
		<pubDate>Sun, 18 May 2008 02:49:15 +0000</pubDate>
		<dc:creator>sssbharathi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sssbharathi.wordpress.com/2008/05/18/india-is-a-land-of-billion-opportunities/</guid>
		<description><![CDATA[Business leaders across the world must come forward to correct the &#8216;imbalance&#8217; in terms of incomes of the rich and the poor, Mukesh Ambani, chairman of the Reliance Industries said. &#34;We cannot have islands of prosperity in the oceans of poverty and squalor, and for businesses to win respect, they have to come with new [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sssbharathi.wordpress.com&amp;blog=3748082&amp;post=6&amp;subd=sssbharathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><font><b><img align="bottom" alt border="0" hspace="0" src="http://writer.zoho.com:80/ImageDisplay.im?name=221367000000013071/1211078925762_02slid1.jpg&amp;accId=221367000000002007" vspace="0"></p>
<p>B</b>usiness leaders across the world must come forward to correct the &#8216;imbalance&#8217; in terms of incomes of the rich and the poor, Mukesh Ambani, chairman of the Reliance Industries said.</font>
<p><font>&quot;We cannot have islands of prosperity in the oceans of poverty and squalor, and for businesses to win respect, they have to come with new business models that balances the world,&quot; Ambani said in his address at the Waldorf Astoria hotel in New York after the America India Foundation (AIF) honoured him for his economic and philanthropic commitment during its spring gala fund-raising event.</font></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sssbharathi.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sssbharathi.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sssbharathi.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sssbharathi.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sssbharathi.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sssbharathi.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sssbharathi.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sssbharathi.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sssbharathi.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sssbharathi.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sssbharathi.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sssbharathi.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sssbharathi.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sssbharathi.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sssbharathi.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sssbharathi.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sssbharathi.wordpress.com&amp;blog=3748082&amp;post=6&amp;subd=sssbharathi&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://sssbharathi.wordpress.com/2008/05/18/india-is-a-land-of-billion-opportunities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/760fbb9669281633d0dce00548cee740?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sssbharathi</media:title>
		</media:content>

		<media:content url="http://writer.zoho.com:80/ImageDisplay.im?name=221367000000013071/1211078925762_02slid1.jpg&#38;accId=221367000000002007" medium="image" />
	</item>
		<item>
		<title>Login to Zoho with your Google or Yahoo!!</title>
		<link>http://sssbharathi.wordpress.com/2008/05/17/login-to-zoho-with-your-google-or-yahoo/</link>
		<comments>http://sssbharathi.wordpress.com/2008/05/17/login-to-zoho-with-your-google-or-yahoo/#comments</comments>
		<pubDate>Sat, 17 May 2008 16:52:51 +0000</pubDate>
		<dc:creator>sssbharathi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sssbharathi.wordpress.com/2008/05/17/login-to-zoho-with-your-google-or-yahoo/</guid>
		<description><![CDATA[Now you can login to Zoho with your Google or Yahoo! accounts. Below the Zoho Sign-in section, you now have the option to login with your Google or Yahoo! accounts. &#160; &#160; &#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If you already have a Zoho account with your Google or Yahoo! email address, you will be logged in to the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sssbharathi.wordpress.com&amp;blog=3748082&amp;post=5&amp;subd=sssbharathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Now you can login to Zoho with your Google or Yahoo! accounts. Below the Zoho Sign-in section, you now have the option to login with your Google or Yahoo! accounts.<br /> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <a href="http://zoho.com"><img align="bottom" alt border="0" hspace="0" src="http://writer.zoho.com:80/ImageDisplay.im?name=221367000000013055/1211042986331_zohologo.jpg&amp;accId=221367000000002007" vspace="0"></a><br /><span style="color:rgb(0, 0, 0);">If you already have a Zoho account with your Google or Yahoo! email address, </span><span style="background-color:rgb(255, 255, 255);color:rgb(0, 0, 0);">you will be logged in to the Zoho account automatically. If you do not have a Zoho account with your Google or Yahoo email address, then you have the option to either associate the Google or Yahoo email address with your existing Zoho account (under <a href="http://accounts.zoho.com/">Accounts</a>) or you can create a new one</span><span style="color:rgb(0, 0, 0);">. </span></p>
<p><span style="color:rgb(0, 0, 0);">Apart from logging into Zoho with your existing accounts, you also have an option to import contacts from your Google and Yahoo! accounts to the Contacts section under <a href="http://accounts.zoho.com/">Zoho Accounts</a>. </span>
<p>This functionality is also useful for sharing documents. Now you can easily share your documents with your friends who have Google or Yahoo! accounts. They can login to Zoho with their Google or Yahoo! credentials and view shared documents without having to create new Zoho Account.</p>
<p>Here is a useful tip. Under http://accounts.zoho.com, if you add your Gmail and Yahoo email addresses (under &lsquo;My Email IDs&rsquo; section) and confirm them, you&rsquo;ll be able to login to your Zoho Account with either your Zoho Account, Google Account or your Yahoo! Account.</p>
<p><span style="font-weight:bold;">Why this move?</span></p>
<p><a href="http://blogs.zoho.com/wp-content/uploads/2008/05/zoho-lifehacker-poll.png" title="zoho-lifehacker-poll.png"><img align="right" alt="zoho-lifehacker-poll.png" height="279" hspace="10" src="http://blogs.zoho.com/wp-content/uploads/2008/05/zoho-lifehacker-poll.png" width="138"></a>We obviously want many users to try out and use our applications. Apart from that, we noticed that when users try Zoho, they prefer our apps to competition. This <a href="http://lifehacker.com/software/lifehacker-faceoff/zoho-suite-vs-google-docs-315256.php">Lifehacker poll</a> conducted few months back for example gives you a snapshot.  </p>
<p>There are two takeaways from the poll like the one above (and other polls we conducted). </p>
<ol>
<li>Many users don&rsquo;t prefer creating yet another account for yet another online app
<li>Users prefer Zoho to Competition when they try both (In case of the above poll, around 75% prefer Zoho)</ol>
<p>We hope this little feature is useful. More than these polls, we want to hear from you if this is useful. Please do let us know your feedback.</p>
<p><strong>Update:</strong> FAQs on this is available <a href="http://zoho.com/sso-help.html">here</a>. Also, <a href="http://zohostatic.com/iam/zgy.gif">this image</a> gives you the flow.</p>
<p>
<p>source: http://blogs.zoho.com</p>
<p></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sssbharathi.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sssbharathi.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sssbharathi.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sssbharathi.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sssbharathi.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sssbharathi.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sssbharathi.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sssbharathi.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sssbharathi.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sssbharathi.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sssbharathi.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sssbharathi.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sssbharathi.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sssbharathi.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sssbharathi.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sssbharathi.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sssbharathi.wordpress.com&amp;blog=3748082&amp;post=5&amp;subd=sssbharathi&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://sssbharathi.wordpress.com/2008/05/17/login-to-zoho-with-your-google-or-yahoo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/760fbb9669281633d0dce00548cee740?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sssbharathi</media:title>
		</media:content>

		<media:content url="http://writer.zoho.com:80/ImageDisplay.im?name=221367000000013055/1211042986331_zohologo.jpg&#38;accId=221367000000002007" medium="image" />

		<media:content url="http://blogs.zoho.com/wp-content/uploads/2008/05/zoho-lifehacker-poll.png" medium="image">
			<media:title type="html">zoho-lifehacker-poll.png</media:title>
		</media:content>
	</item>
		<item>
		<title>Struts Bean Tags</title>
		<link>http://sssbharathi.wordpress.com/2008/05/17/struts-bean-tags/</link>
		<comments>http://sssbharathi.wordpress.com/2008/05/17/struts-bean-tags/#comments</comments>
		<pubDate>Sat, 17 May 2008 16:23:54 +0000</pubDate>
		<dc:creator>sssbharathi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sssbharathi.wordpress.com/2008/05/17/struts-bean-tags/</guid>
		<description><![CDATA[Struts Bean Tags This tag library contains tags useful in accessing beans and their properties, as well as defining new beans (based on these accesses) that are accessible to the remainder of the page via scripting variables and page scope attributes. Convenient mechanisms to create new beans based on the value of request cookies, headers, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sssbharathi.wordpress.com&amp;blog=3748082&amp;post=4&amp;subd=sssbharathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Struts Bean Tags</h2>
<div class="indent">
<p>This tag library contains tags useful in accessing beans and their   properties, as well as defining new beans (based on these accesses)   that are accessible to the remainder of the page via scripting variables   and page scope attributes.  Convenient mechanisms to create new beans   based on the value of request cookies, headers, and parameters are also   provided.</p>
<p>Many of the tags in this tag library will throw a   <code>JspException</code> at runtime when they are utilized incorrectly   (such as when you specify an invalid combination of tag attributes).  JSP   allows you to declare an &quot;error page&quot; in the <code>&lt;%@ page %&gt;</code>   directive.  If you wish to process the actual exception that caused the   problem, it is passed to the error page as a request attribute under key   <code>org.apache.struts.action.EXCEPTION</code>.</p>
<p>If you are viewing this page from within the Struts Documentation   Application (or online at <a href="http://struts.apache.org/">   http://struts.apache.org/</a>), you can learn more about using   these tags in the   <a href="http://struts.apache.org/1.2.x/api/org/apache/struts/taglib/bean/package-summary.html#package_description">   Bean Tags Developer&#8217;s Guide</a>.</p>
<table class="taglib-summary">
<thead>
<tr>
<th>Tag Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="evenRow">
<td align="center"><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#cookie">cookie</a></td>
<td>     Define a scripting variable based on the value(s) of the specified     request cookie.     </td>
</tr>
<tr class="oddRow">
<td align="center"><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#define">define</a></td>
<td>     Define a scripting variable based on the value(s) of the specified     bean property.     </td>
</tr>
<tr class="evenRow">
<td align="center"><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#header">header</a></td>
<td>     Define a scripting variable based on the value(s) of the specified     request header.     </td>
</tr>
<tr class="oddRow">
<td align="center"><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#include">include</a></td>
<td>     Load the response from a dynamic application request and make it available     as a bean.     </td>
</tr>
<tr class="evenRow">
<td align="center"><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#message">message</a></td>
<td>     Render an internationalized message string to the response.     </td>
</tr>
<tr class="oddRow">
<td align="center"><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#page">page</a></td>
<td>     Expose a specified item from the page context as a bean.     </td>
</tr>
<tr class="evenRow">
<td align="center"><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#parameter">parameter</a></td>
<td>     Define a scripting variable based on the value(s) of the specified     request parameter.     </td>
</tr>
<tr class="oddRow">
<td align="center"><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#resource">resource</a></td>
<td>     Load a web application resource and make it available as a bean.     </td>
</tr>
<tr class="evenRow">
<td align="center"><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#size">size</a></td>
<td>     Define a bean containing the number of elements in a Collection or Map.     </td>
</tr>
<tr class="oddRow">
<td align="center"><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#struts">struts</a></td>
<td>     Expose a named Struts internal configuration object as a bean.     </td>
</tr>
<tr class="evenRow">
<td align="center"><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#write">write</a></td>
<td>     Render the value of the specified bean property to the current     JspWriter.     </td>
</tr>
</tbody>
</table>
</div>
<h3><strong>cookie</strong> &#8211;      Define a scripting variable based on the value(s) of the specified     request cookie.     </h3>
<div class="indent">
<p>Retrieve the value of the specified request cookie (as a single     value or multiple values, depending on the <code>multiple</code> attribute),     and define the result as a page scope attribute of type <code>Cookie</code>     (if <code>multiple</code> is not specified) or <code>Cookie[]</code>     (if <code>multiple</code> is specified).</p>
<p>If no cookie with the specified name can be located, and no default     value is specified, a request time exception will be thrown.</p>
<table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="evenRow">
<td align="center">id</td>
<td>
<p>Specifies the name of the scripting variable (and associated page       scope attribute) that will be made available with the value of the       specified request cookie.</p>
<p>                    [Required]           </td>
</tr>
<tr class="oddRow">
<td align="center">multiple</td>
<td>
<p>If any arbitrary value for this attribute is specified, causes all       matching cookies to be accumulated and stored into a bean of type       <code>Cookie[]</code>.  If not specified, the first value for the       specified cookie will be retrieved as a value of type       <code>Cookie</code>.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">name</td>
<td>
<p>Specifies the name of the request cookie whose value, or values,       is to be retrieved.</p>
<p>                    [Required]                        [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">value</td>
<td>
<p>The default cookie value to return if no cookie with the       specified name was included in this request.</p>
<p>                    [RT Expr]           </td>
</tr>
</tbody>
</table>
</div>
<p><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#top">Back to top</a></p>
<h3><strong>define</strong> &#8211;      Define a scripting variable based on the value(s) of the specified     bean property.     </h3>
<div class="indent">
<p>Create a new attribute (in the scope specified by the     <code>toScope</code> property, if any), and a corresponding scripting     variable, both of which are named by the value of the <code>id</code>     attribute.  The corresponding value to which this new attribute (and     scripting variable) is set are specified via use of exactly one of the     following approaches (trying to use more than one will result in a     JspException being thrown):</p>
<ul>
<li>Specify a <code>name</code> attribute (plus optional         <code>property</code> and <code>scope</code> attributes) &#8211;         The created attribute and scripting variable will be of the type of the         retrieved JavaBean property, unless it is a Java primitive type,         in which case it will be wrapped in the appropriate wrapper class         (i.e. int is wrapped by java.lang.Integer).
<li>Specify a <code>value</code> attribute &#8211; The created attribute and         scripting variable will be of type <code>java.lang.String</code>,         set to the value of this attribute.
<li>Specify nested body content &#8211; The created attribute and scripting         variable will be of type <code>java.lang.String</code>, set to         the value of the nested body content.</ul>
<p>If a problem occurs while retrieving the specified bean property, a     request time exception will be thrown.</p>
<p>The <code>&lt;bean:define&gt;</code> tag differs from     <code>&lt;jsp:useBean&gt;</code> in several ways, including:</p>
<ul>
<li>Unconditionally creates (or replaces) a bean under the         specified identifier.
<li>Can create a bean with the value returned by a property getter         of a different bean (including properties referenced with a         nested and/or indexed property name).
<li>Can create a bean whose contents is a literal string (or the result         of a runtime expression) specified by the <code>value</code>         attribute.
<li>Does not support nested content (such as         <code>&lt;jsp:setProperty&gt;</code> tags) that are only executed         if a bean was actually created.</ul>
<p><strong>USAGE NOTE</strong> &#8211; There is a restriction in the JSP 1.1     Specification that disallows using the same value for an <code>id</code>     attribute more than once in a single JSP page.  Therefore, you will not     be able to use <code>&lt;bean:define&gt;</code> for the same bean     name more than once in a single page.</p>
<p><strong>USAGE NOTE</strong> &#8211; If you use another tag to create the     body content (e.g. bean:write), that tag must return a non-empty String.     An empty String equates to an empty body or a null String, and a new     scripting variable cannot be defined as null. Your bean must return a     non-empty String, or the define tag must be wrapped within a logic tag     to test for an empty or null value.</p>
<p><strong>USAGE NOTE</strong> &#8211; You cannot use bean:define to <strong>instantiate</strong>     a DynaActionForm (type=&quot;org.apache.struts.action.DynaActionForm&quot;) with     the properties specified in the struts-config. The mechanics of creating     the dyna-properties is complex and cannot be handled by a no-argument     constructor. If you need to create an ActionForm this way, you must use     a conventional ActionForm.     </p>
<p>See the Bean Developer&#8217;s Guide section on     <a href="http://struts.apache.org/1.2.x/api/org/apache/struts/taglib/bean/package-summary.html#doc.Creation">     bean creation</a> for more information about these differences, as well     as alternative approaches to introducing beans into a JSP page.</p>
<table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="evenRow">
<td align="center">id</td>
<td>
<p>Specifies the name of the scripting variable (and associated page       scope attribute) that will be made available with the value of the       specified property.</p>
<p>                    [Required]           </td>
</tr>
<tr class="oddRow">
<td align="center">name</td>
<td>
<p>Specifies the attribute name of the bean whose property is accessed       to define a new page scope attribute (if <code>property</code> is also       specified) or the attribute name of the bean that is duplicated with       the new reference created by this tag (if <code>property</code> is not       also specified).  This attribute is required unless you specify       a <code>value</code> attribute or nested body content.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">property</td>
<td>
<p>Specifies the name of the property to be accessed on the bean       specified by <code>name</code>.  This value may be a simple, indexed,       or nested property reference expression.  If not specified, the bean       identified by <code>name</code> is given a new reference identified by       <code>id</code>.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">scope</td>
<td>
<p>Specifies the variable scope searched to retrieve the bean specified       by <code>name</code>.  If not specified, the default rules applied by       <code>PageContext.findAttribute()</code> are applied.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">toScope</td>
<td>
<p>Specifies the variable scope into which the newly defined bean will       be created.  If not specified, the bean will be created in       <code>page</code> scope.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">type</td>
<td>
<p>Specifies the fully qualified class name of the value to be exposed         as the <code>id</code> attribute.</p>
<p>                    [         java.lang.String (if you specify a value         attribute) or java.lang.Object otherwise.       ]                        [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">value</td>
<td>
<p>The <code>java.lang.String</code> value to which the exposed bean       should be set.  This attribute is required unless you specify the       <code>name</code> attribute or nested body content.</p>
<p>                    [RT Expr]           </td>
</tr>
</tbody>
</table>
</div>
<p><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#top">Back to top</a></p>
<h3><strong>header</strong> &#8211;      Define a scripting variable based on the value(s) of the specified     request header.     </h3>
<div class="indent">
<p>Retrieve the value of the specified request header (as a single     value or multiple values, depending on the <code>multiple</code> attribute),     and define the result as a page scope attribute of type <code>String</code>     (if <code>multiple</code> is not specified) or <code>String[]</code>     (if <code>multiple</code> is specified).</p>
<p>If no header with the specified name can be located, and no default     value is specified, a request time exception will be thrown.</p>
<table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="evenRow">
<td align="center">id</td>
<td>
<p>Specifies the name of the scripting variable (and associated page       scope attribute) that will be made available with the value of the       specified request header.</p>
<p>                    [Required]           </td>
</tr>
<tr class="oddRow">
<td align="center">multiple</td>
<td>
<p>If any arbitrary value for this attribute is specified, causes a call       to <code>HttpServletRequest.getHeaders()</code> and a definition of the       result as a bean of type <code>String[]</code>.  Otherwise,       <code>HttpServletRequest.getHeader()</code> will be called, and a       definition of the result as a bean of type <code>String</code>       will be performed.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">name</td>
<td>
<p>Specifies the name of the request header whose value, or values,       is to be retrieved.</p>
<p>                    [Required]                        [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">value</td>
<td>
<p>The default header value to return if no header with the       specified name was included in this request.</p>
<p>                    [RT Expr]           </td>
</tr>
</tbody>
</table>
</div>
<p><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#top">Back to top</a></p>
<h3><strong>include</strong> &#8211;      Load the response from a dynamic application request and make it available     as a bean.     </h3>
<div class="indent">
<p>Perform an internal dispatch to the specified application component     (or external URL)     and make the response data from that request available as a bean of     type <code>String</code>.  This tag has a function similar to that of     the standard <code>&lt;jsp:include&gt;</code> tag, except that the     response data is stored in a page scope attribute instead of being     written to the output stream.  If the current request is part of a     session, the generated request for the include will also include the     session identifier (and thus be part of the same session).</p>
<p>The URL used to access the specified application component is     calculated based on which of the following attributes you specify     (you must specify exactly one of them):</p>
<ul>
<li><em>forward</em> &#8211; Use the value of this attribute as the name         of a global <code>ActionForward</code> to be looked up, and         use the module-relative or context-relative URI found there.
<li><em>href</em> &#8211; Use the value of this attribute unchanged (since         this might link to a resource external to the application, the         session identifier is <strong>not</strong> included.
<li><em>page</em> &#8211; Use the value of this attribute as an         module-relative URI to the desired resource.</ul>
<table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="evenRow">
<td align="center">anchor</td>
<td>
<p>Optional anchor tag (&quot;#xxx&quot;) to be added to the generated       hyperlink.  Specify this value <strong>without</strong> any       &quot;#&quot; character.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">forward</td>
<td>
<p>Logical name of a global <code>ActionForward</code> that contains       the actual content-relative URI of the resource to be included.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">href</td>
<td>
<p>Absolute URL (including the appropriate protocol prefix such as       &quot;http:&quot;) of the resource to be included.  Because this URL could be       external to the current web application, the session identifier will       <strong>not</strong> be included in the request.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">id</td>
<td>
<p>Specifies the name of the scripting variable (and associated page       scope attribute) that will be made available with the value of the       specified web application resource.</p>
<p>                    [Required]           </td>
</tr>
<tr class="evenRow">
<td align="center">name</td>
<td>
<p>Module-relative name (starting with a &#8216;/&#8217;) of the web application       resource to be dispatched, and whose response data is to be made       available as a bean.</p>
<p class="deprecated"><strong>DEPRECATED:</strong>       Use the &quot;page&quot; attribute instead.       </p>
<p>             [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">page</td>
<td>
<p>Module-relative URI (starting with a &#8216;/&#8217;) of the web application       resource to be included.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">transaction</td>
<td>
<p>Set to <code>true</code> if you want the current         transaction control token included in the generated         URL for this include.</p>
<p>                    [RT Expr]           </td>
</tr>
</tbody>
</table>
</div>
<p><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#top">Back to top</a></p>
<h3><strong>message</strong> &#8211;      Render an internationalized message string to the response.     </h3>
<div class="indent">
<p>Retrieves an internationalized message for the specified locale,     using the specified message key, and write it to the output stream.     Up to five parametric replacements (such as &quot;{0}&quot;) may be specified.</p>
<p>The message key may be specified directly, using the <code>key</code>     attribute, or indirectly, using the <code>name</code> and     <code>property</code> attributes to obtain it from a bean.</p>
<p><strong>JSTL</strong>:  The equivalent JSTL tag is &lt;fmt:message&gt;.  For example,     <br /><code>      &lt;fmt:message key=&quot;my.msg.key&quot;&gt;        &lt;fmt:param value=&quot;replacement text&quot;/&gt;      &lt;/fmt:message&gt;     </code></p>
<table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="evenRow">
<td align="center">arg0</td>
<td>
<p>First parametric replacement value, if any.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">arg1</td>
<td>
<p>Second parametric replacement value, if any.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">arg2</td>
<td>
<p>Third parametric replacement value, if any.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">arg3</td>
<td>
<p>Fourth parametric replacement value, if any.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">arg4</td>
<td>
<p>Fifth parametric replacement value, if any.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">bundle</td>
<td>
<p>The name of the application scope bean under which the       <code>MessageResources</code> object containing our messages       is stored.</p>
<p>                    [Globals.MESSAGES_KEY]                        [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">key</td>
<td>
<p>The message key of the requested message, which must have       a corresponding value in the message resources. If not specified,       the key is obtained from the <code>name</code> and       <code>property</code> attributes.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">locale</td>
<td>
<p>The name of the session scope bean under which our currently       selected <code>Locale</code> object is stored.</p>
<p>                    [Globals.LOCALE_KEY]                        [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">name</td>
<td>
<p>Specifies the attribute name of the bean whose property is accessed       to retrieve the value specified by <code>property</code> (if       specified).  If <code>property</code> is not specified, the value of       this bean itself will be used as the message resource key.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">property</td>
<td>
<p>Specifies the name of the property to be accessed on the bean       specified by <code>name</code>.  This value may be a simple, indexed,       or nested property reference expression.  If not specified, the value       of the bean identified by <code>name</code> will itself be used as the       message resource key.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">scope</td>
<td>
<p>Specifies the variable scope searched to retrieve the bean specified       by <code>name</code>.  If not specified, the default rules applied by       <code>PageContext.findAttribute()</code> are applied.</p>
<p>                    [RT Expr]           </td>
</tr>
</tbody>
</table>
</div>
<p><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#top">Back to top</a></p>
<h3><strong>page</strong> &#8211;      Expose a specified item from the page context as a bean.     </h3>
<div class="indent">
<p>Retrieve the value of the specified item from the page context     for this page, and define it as a scripting variable, and a page scope     attribute accessible to the remainder of the current page.</p>
<p>If a problem occurs while retrieving the specified configuration     object, a request time exception will be thrown.</p>
<table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="evenRow">
<td align="center">id</td>
<td>
<p>Specifies the name of the scripting variable (and associated       page scope attribute) that will be made available with the value of       the specified page context property.</p>
<p>                    [Required]           </td>
</tr>
<tr class="oddRow">
<td align="center">property</td>
<td>
<p>Name of the property from our page context to be retrieved and       exposed.  Must be one of <code>application</code>, <code>config</code>,       <code>request</code>, <code>response</code>, or <code>session</code>.       </p>
<p>                    [Required]                        [RT Expr]           </td>
</tr>
</tbody>
</table>
</div>
<p><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#top">Back to top</a></p>
<h3><strong>parameter</strong> &#8211;      Define a scripting variable based on the value(s) of the specified     request parameter.     </h3>
<div class="indent">
<p>Retrieve the value of the specified request parameter (as a single     value or multiple values, depending on the <code>multiple</code> attribute),     and define the result as a page scope attribute of type <code>String</code>     (if <code>multiple</code> is not specified) or <code>String[]</code>     (if <code>multiple</code> is specified).</p>
<p>If no request parameter with the specified name can be located, and     no default value is specified, a request time exception will be thrown.</p>
<table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="evenRow">
<td align="center">id</td>
<td>
<p>Specifies the name of the scripting variable (and associated page       scope attribute) that will be made available with the value of the       specified request parameter.</p>
<p>                    [Required]           </td>
</tr>
<tr class="oddRow">
<td align="center">multiple</td>
<td>
<p>If any arbitrary value for this attribute is specified, causes a call       to <code>ServletRequest.getParameterValues()</code> and a definition of       the result as a bean of type <code>String[]</code>.  Otherwise,       <code>ServletRequest.getParameter()</code> will be called, and a       definition of the result as a bean of type <code>String</code>       will be performed.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">name</td>
<td>
<p>Specifies the name of the request parameter whose value, or values,       is to be retrieved.</p>
<p>                    [Required]                        [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">value</td>
<td>
<p>The default parameter value to return if no parameter with the       specified name was included in this request.</p>
<p>                    [RT Expr]           </td>
</tr>
</tbody>
</table>
</div>
<p><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#top">Back to top</a></p>
<h3><strong>resource</strong> &#8211;      Load a web application resource and make it available as a bean.     </h3>
<div class="indent">
<p>Retrieve the value of the specified web application resource, and make     it available as either a <code>InputStream</code> or a <code>String</code>,     depending on the value of the <code>input</code> attribute.</p>
<p>If a problem occurs while retrieving the specified resource, a     request time exception will be thrown.</p>
<table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="evenRow">
<td align="center">id</td>
<td>
<p>Specifies the name of the scripting variable (and associated page       scope attribute) that will be made available with the value of the       specified web application resource.</p>
<p>                    [Required]           </td>
</tr>
<tr class="oddRow">
<td align="center">input</td>
<td>
<p>If any arbitrary value for this attribute is specified, the resource       will be made available as an <code>InputStream</code>.  If this       attribute is not specified, the resource will be made available       as a <code>String</code>.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">name</td>
<td>
<p>Module-relative name (starting with a &#8216;/&#8217;) of the web application       resource to be loaded and made available.</p>
<p>                    [Required]                        [RT Expr]           </td>
</tr>
</tbody>
</table>
</div>
<p><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#top">Back to top</a></p>
<h3><strong>size</strong> &#8211;      Define a bean containing the number of elements in a Collection or Map.     </h3>
<div class="indent">
<p>Given a reference to an array, Collection or Map, creates a new bean, of     type <code>java.lang.Integer</code>, whose value is the number of elements     in that collection.  You can specify the collection to be counted in any     one of the following ways:</p>
<ul>
<li>As a runtime expression specified as the value of the         <code>collection</code> attribute.
<li>As a JSP bean specified by the <code>name</code> attribute.
<li>As the property, specified by the <code>property</code> attribute,         of the JSP bean specified by the <code>name</code> attribute.</ul>
<table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="evenRow">
<td align="center">collection</td>
<td>
<p>A runtime expression that evaluates to an array, a Collection, or       a Map.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">id</td>
<td>
<p>The name of a page scope JSP bean, of type       <code>java.lang.Integer</code>, that will be created to contain the       size of the underlying collection being counted.</p>
<p>                    [Required]           </td>
</tr>
<tr class="evenRow">
<td align="center">name</td>
<td>
<p>The name of the JSP bean (optionally constrained to the scope       specified by the <code>scope</code> attribute) that contains the       collection to be counted (if <code>property</code> is not specified),       or whose property getter is called to return the collection to be       counted (if <code>property</code> is specified.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">property</td>
<td>
<p>The name of the property, of the bean specified by the       <code>name</code> attribute, whose getter method will return the       collection to be counted.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">scope</td>
<td>
<p>The bean scope within which to search for the JSP bean specified       by the <code>name</code> attribute.  If not specified, the available       scopes are searched in ascending sequence.</p>
<p>                    [RT Expr]           </td>
</tr>
</tbody>
</table>
</div>
<p><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#top">Back to top</a></p>
<h3><strong>struts</strong> &#8211;      Expose a named Struts internal configuration object as a bean.     </h3>
<div class="indent">
<p>Retrieve the value of the specified Struts internal configuration     object, and define it as a scripting variable and as a page scope     attribute accessible to the remainder of the current page.  You must     specify exactly one of the <code>formBean</code>, <code>forward</code>,     and <code>mapping</code> attributes to select the configuration object     to be exposed.</p>
<p>If a problem occurs while retrieving the specified configuration     object, a request time exception will be thrown.</p>
<table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="evenRow">
<td align="center">id</td>
<td>
<p>Specifies the name of the scripting variable (and associated       page scope attribute) that will be made available with the value of       the specified Struts internal configuration object.</p>
<p>                    [Required]           </td>
</tr>
<tr class="oddRow">
<td align="center">formBean</td>
<td>
<p>Specifies the name of the Struts <code>ActionFormBean</code>       definition object to be exposed.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">forward</td>
<td>
<p>Specifies the name of the global Struts <code>ActionForward</code>       definition object to be exposed.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">mapping</td>
<td>
<p>Specifies the matching path of the Struts <code>ActionMapping</code>       definition object to be exposed.</p>
<p>                    [RT Expr]           </td>
</tr>
</tbody>
</table>
</div>
<p><a href="http://struts.apache.org/1.2.x/userGuide/struts-bean.html#top">Back to top</a></p>
<h3><strong>write</strong> &#8211;      Render the value of the specified bean property to the current     JspWriter.     </h3>
<div class="indent">
<p>Retrieve the value of the specified bean property, and render it to the     current JspWriter as a String by the ways:</p>
<ul>
<li>If <code>format</code> attribute exists then value will be formatted on base of format      string from <code>format</code> attribute and default system locale.
<li>If in resources exists format string for value data type (view <code>format</code>      attribute description) then value will be formatted on base of format string      from resources. Resources bundle and target locale can be specified with      <code>bundle</code> and <code>locale</code> attributes. If nothing specified then      default resource bundle and current user locale will be used.
<li>If there is a PropertyEditor configured for the property value&#8217;s class, the      <code>getAsText()</code> method will be called.
<li>Otherwise, the usual <code>toString()</code> conversions will be applied.</ul>
<p>When a format string is provided, numeric values are formatted using the     <code>java.text.DecimalFormat</code> class; if the format string came from     a resource, the <code>applyLocalisedPattern()</code> method is used, and     <code>applyPattern()</code> is used otherwise. Dates are formatted using     the <code>SimpleDateFormat</code> class. For details of the specific format     patterns, please see the Javadocs for those classes.</p>
<p>If a problem occurs while retrieving the specified bean property, a     request time exception will be thrown.</p>
<table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="evenRow">
<td align="center">bundle</td>
<td>
<p>The name of the application scope bean under which the       <code>MessageResources</code> object containing our messages       is stored.</p>
<p>                    [Globals.MESSAGES_KEY]                        [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">filter</td>
<td>
<p>If this attribute is set to <code>true</code>, the rendered property       value will be filtered for characters that are sensitive in HTML, and any       such characters will be replaced by their entity equivalents.</p>
<p>                    [true]                        [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">format</td>
<td>
<p>Specifies the format string to use to convert bean or property value       to the <code>String</code>. If nothing specified, then default format       string for value data type will be searched in message resources by       according key.</p>
<p>                     [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">formatKey</td>
<td>
<p>Specifies the key to search format string in application resources.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">ignore</td>
<td>
<p>If this attribute is set to <code>true</code>, and the bean specified       by the <code>name</code> and <code>scope</code> attributes does not       exist, simply return without writing anything.  If this attribute is       set to <code>false</code>, a runtime exception to be thrown,       consistent with the other tags in this tag library.</p>
<p>                    [false]                        [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">locale</td>
<td>
<p>The name of the session scope bean under which our currently         selected <code>Locale</code> object is stored.</p>
<p>                    [Globals.LOCALE_KEY]                        [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">name</td>
<td>
<p>Specifies the attribute name of the bean whose property is accessed       to retrieve the value specified by <code>property</code> (if       specified).  If <code>property</code> is not specified, the value of       this bean itself will be rendered.</p>
<p>                    [Required]                        [RT Expr]           </td>
</tr>
<tr class="oddRow">
<td align="center">property</td>
<td>
<p>Specifies the name of the property to be accessed on the bean       specified by <code>name</code>.  This value may be a simple, indexed,       or nested property reference expression.  If not specified, the bean       identified by <code>name</code> will itself be rendered.  If the       specified property returns null, no output will be rendered.</p>
<p>                    [RT Expr]           </td>
</tr>
<tr class="evenRow">
<td align="center">scope</td>
<td>
<p>Specifies the variable scope searched to retrieve the bean specified       by <code>name</code>.  If not specified, the default rules applied by       <code>PageContext.findAttribute()</code> are applied.</p>
<p>                    [RT Expr]           </td>
</tr>
</tbody>
</table>
</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sssbharathi.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sssbharathi.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sssbharathi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sssbharathi.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sssbharathi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sssbharathi.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sssbharathi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sssbharathi.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sssbharathi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sssbharathi.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sssbharathi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sssbharathi.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sssbharathi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sssbharathi.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sssbharathi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sssbharathi.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sssbharathi.wordpress.com&amp;blog=3748082&amp;post=4&amp;subd=sssbharathi&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://sssbharathi.wordpress.com/2008/05/17/struts-bean-tags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/760fbb9669281633d0dce00548cee740?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sssbharathi</media:title>
		</media:content>
	</item>
		<item>
		<title>JSP Tutorial</title>
		<link>http://sssbharathi.wordpress.com/2008/05/17/jsp-tutorial/</link>
		<comments>http://sssbharathi.wordpress.com/2008/05/17/jsp-tutorial/#comments</comments>
		<pubDate>Sat, 17 May 2008 05:09:46 +0000</pubDate>
		<dc:creator>sssbharathi</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sssbharathi.wordpress.com/2008/05/17/jsp-tutorial/</guid>
		<description><![CDATA[JSP Tutorial Tutorial Overview The prerequisites for the tutorial are: HTML. You should be able to put together HTML pages. Java. You should be able to program in Java. This tutorial teaches JSP by progressing from very simple examples to complex examples. Advanced learners may want to do a quick review of the introductory material [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sssbharathi.wordpress.com&amp;blog=3748082&amp;post=3&amp;subd=sssbharathi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong><span style="font-size:small;">JSP Tutorial</span></strong></p>
<h2>Tutorial Overview</h2>
<p>The prerequisites for the tutorial are:</p>
<ul>
<li> HTML.  You should be able to put together HTML pages.</li>
<li> Java.  You should be able to program in Java.</li>
</ul>
<p>This tutorial teaches JSP by progressing from very simple examples to complex examples.</p>
<p>Advanced learners may want to do a quick review of the introductory material and skip to the lessons appropriate to their level.</p>
<p><a name="contents"></a>The steps in the tutorial are outlined below:</p>
<ol>
<li><a href="http://www.jsptut.com/Getfamiliar.jsp">Getting familiar with your JSP server</a></li>
<li><a href="http://www.jsptut.com/FirstJsp.jsp">Your first JSP</a></li>
<li><a href="http://www.jsptut.com/Dynexpr.jsp">Adding dynamic content via expressions</a></li>
<li><a href="http://www.jsptut.com/Scriptlets.jsp">Scriptlets</a></li>
<li><a href="http://www.jsptut.com/Mixing.jsp">Mixing Scriptlets and HTML</a></li>
<li><a href="http://www.jsptut.com/Directives.jsp">Directives</a></li>
<li><a href="http://www.jsptut.com/Declarations.jsp">Declarations</a></li>
<li><a href="http://www.jsptut.com/Tags.jsp">Tags</a></li>
<li><a href="http://www.jsptut.com/Sessions.jsp">Sessions</a></li>
<li><a href="http://www.jsptut.com/Forms.jsp">Beans and Forms Processing</a></li>
<li><a href="http://www.jsptut.com/Taglibs.jsp">Tag Libraries</a></li>
<li><a href="http://www.jsptut.com/Editing.jsp">Form Editing</a></li>
<li><a href="http://www.jsptut.com/Loginforms.jsp">Log-in pages</a>&lt;!&#8211;</li>
<li><a href="Sql.jsp">SQL</a></li>
<li><a href="Email.jsp">Sending Email</a></li>
<p>&#8211;&gt;</p>
<li><a href="http://www.jsptut.com/Further.jsp">Further learning</a></li>
</ol>
<h2>Getting Familiar with your JSP server</h2>
<p>If you do not have a JSP capable web-server or <em>application server</em>, the first step is to download one.  There are many such servers available, most of which can be downloaded for free evaluation and/or development.  Some of them are:</p>
<blockquote><p><a href="http://www.blazix.com/blazix.html" target="_new">Blazix</a> from Desiderata Software (<em>1.5 Megabytes, JSP, Servlets and EJBs</em>)<br />
<a href="http://tomcat.apache.org/" target="_new">TomCat</a> from Apache (<em>Approx 6 Megabytes</em>)<br />
<a href="http://www.beasys.com/" target="_new">WebLogic</a> from BEA Systems (<em>Approx 40 Megabytes, JSP, Servlets and EJBs</em>)<br />
<a href="http://www-4.ibm.com/software/webservers/" target="_new">WebSphere</a> from IBM (<em>Approx 100 Megabytes, JSP, Servlets and EJBs</em>)</p></blockquote>
<p>To take the best advantage of this tutorial, it recommended that all the material should be tried out with a real server.</p>
<p>Once you have a JSP capable web-server or application server, you need to know the following information about it:</p>
<ul>
<li> Where to place the files</li>
<li> How to access the files from your browser (with an <tt>http:</tt> prefix, not as <tt>file:</tt>)</li>
</ul>
<p>You should be able to create a simple file, such as</p>
<blockquote>
<pre><tt>&lt;HTML&gt;&lt;BODY&gt;Hello, world&lt;/BODY&gt;&lt;/HTML&gt;</tt></pre>
</blockquote>
<p>know where to place this file and how to see it in your browser with an <tt>http://</tt> prefix. Since this step is different for each web-server, you would need to see the web-server documentation to find out how this is done.  Once you have completed this step, proceed to the next tutorial.</p>
<h2>Your first JSP</h2>
<p>JSP simply puts Java inside HTML pages.  You can take any existing HTML page and change its extension to &#8220;.jsp&#8221; instead of &#8220;.html&#8221;.  In fact, this is the perfect exercise for your first JSP.</p>
<p>Take the HTML file you used in the <a href="http://www.jsptut.com/Getfamiliar.jsp">previous exercise</a>.  Change its extension from &#8220;.html&#8221; to &#8220;.jsp&#8221;.  Now load the new file, with the &#8220;.jsp&#8221; extension, in your browser.</p>
<p>You will see the same output, but it will take longer!  But only the first time.  If you reload it again, it will load normally.</p>
<p>What is happening behind the scenes is that your JSP is being turned into a Java file, compiled and loaded.  This compilation only happens once, so after the first load, the file doesn&#8217;t take long to load anymore.  (But everytime you change the JSP file, it will be re-compiled again.)</p>
<p>Of course, it is not very useful to just write HTML pages with a .jsp extension!  We now proceed to see what makes JSP so useful.</p>
<h2>Adding dynamic content via expressions</h2>
<p>As we saw in the previous section, any HTML file can be turned into a JSP file by changing its extension to .jsp.  Of course, what makes JSP useful is the ability to embed Java.  Put the following text in a file with .jsp extension (let us call it <strong><tt>hello.jsp</tt></strong>), place it in your JSP directory, and view it in a browser.</p>
<pre>&lt;HTML&gt;&lt;BODY&gt;Hello!  The time is now &lt;%= new java.util.Date() %&gt;&lt;/BODY&gt;&lt;/HTML&gt;</pre>
<p>Notice that each time you reload the page in the browser, it comes up with the current time.</p>
<p>The character sequences <tt>&lt;%=</tt> and <tt>%&gt;</tt> enclose Java expressions, which are evaluated at run time.</p>
<p>This is what makes it possible to use JSP to generate dyamic HTML pages that change in response to user actions or vary from user to user.</p>
<p><em>Exercise:</em> Write a JSP to output the values returned by <tt>System.getProperty</tt> for various system properties such as <tt>java.version, java.home, os.name, user.name, user.home, user.dir</tt> etc.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>
<table style="cursor:pointer;" border="2" width="80%">
<tbody>
<tr>
<td align="center"></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<h2>Scriptlets</h2>
<p>We have already seen how to embed Java expressions in JSP pages by putting them between the <strong><tt>&lt;%=</tt></strong> and <strong><tt>%&gt;</tt></strong> character sequences.</p>
<p>But it is difficult to do much programming just by putting Java expressions inside HTML.</p>
<p>JSP also allows you to write blocks of Java code inside the JSP.  You do this by placing your Java code between <strong><tt>&lt;%</tt></strong> and <strong><tt>%&gt;</tt></strong> characters (just like expressions, but without the <strong><tt>=</tt></strong> sign at the start of the sequence.)</p>
<p>This block of code is known as a &#8220;scriptlet&#8221;.  By itself, a scriptlet doesn&#8217;t contribute any HTML (though it can, as we will see down below.)  A scriptlet contains Java code that is executed every time the JSP is invoked.</p>
<p>Here is a modified version of our JSP from previous section, adding in a scriptlet.</p>
<pre>&lt;HTML&gt;&lt;BODY&gt;&lt;%    // This is a scriptlet.  Notice that the "date"    // variable we declare here is available in the    // embedded expression later on.    System.out.println( "Evaluating date now" );    java.util.Date date = new java.util.Date();%&gt;Hello!  The time is now &lt;%= date %&gt;&lt;/BODY&gt;&lt;/HTML&gt;</pre>
<p>If you run the above example, you will notice the output from the &#8220;<tt>System.out.println</tt>&#8221; on the server log.  This is a convenient way to do simple debugging (some servers also have techniques of debugging the JSP in the IDE.  See your server&#8217;s documentation to see if it offers such a technique.)</p>
<p>By itself a scriptlet does not generate HTML.  If a scriptlet wants to generate HTML, it can use a variable called &#8220;<tt>out</tt>&#8220;.  This variable does not need to be declared.  It is already predefined for scriptlets, along with some other variables.  The following example shows how the scriptlet can generate HTML output.</p>
<pre>&lt;HTML&gt;&lt;BODY&gt;&lt;%    // This scriptlet declares and initializes "date"    System.out.println( "Evaluating date now" );    java.util.Date date = new java.util.Date();%&gt;Hello!  The time is now&lt;%    // This scriptlet generates HTML output    out.println( String.valueOf( date ));%&gt;&lt;/BODY&gt;&lt;/HTML&gt;</pre>
<p>Here, instead of using an expression, we are generating the HTML directly by printing to the &#8220;<tt>out</tt>&#8221; variable.  The &#8220;<tt>out</tt>&#8221; variable is of type <tt><a href="http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/jsp/JspWriter.html">javax.servlet.jsp.JspWriter</a>.</tt></p>
<p>Another very useful pre-defined variable is &#8220;<tt>request</tt>&#8220;.  It is of type <tt><a href="http://java.sun.com/products/servlet/2.1/api/javax.servlet.http.HttpServletRequest.html">javax.servlet.http.HttpServletRequest</a></tt></p>
<p>A &#8220;request&#8221; in server-side processing refers to the transaction between a browser and the server.  When someone clicks or enters a URL, the browser sends a &#8220;request&#8221; to the server for that URL, and shows the data returned.  As a part of this &#8220;request&#8221;, various data is available, including the file the browser wants from the server, and if the request is coming from pressing a SUBMIT button, the information the user has entered in the form fields.</p>
<p>The JSP &#8220;<tt>request</tt>&#8221; variable is used to obtain information from the request as sent by the browser.  For instance, you can find out the name of the client&#8217;s host (if available, otherwise the IP address will be returned.)  Let us modify the code as shown:</p>
<pre>&lt;HTML&gt;&lt;BODY&gt;&lt;%    // This scriptlet declares and initializes "date"    System.out.println( "Evaluating date now" );    java.util.Date date = new java.util.Date();%&gt;Hello!  The time is now&lt;%    out.println( date );    out.println( "&lt;BR&gt;Your machine's address is " );    out.println( request.getRemoteHost());%&gt;&lt;/BODY&gt;&lt;/HTML&gt;</pre>
<p>A similar variable is &#8220;response&#8221;.  This can be used to affect the response being sent to the browser.  For instance, you can call <tt>response.sendRedirect( anotherUrl ); </tt>to send a response to the browser that it should load a different URL.  This response will actualy go all the way to the browser.  The browser will then send a different request, to &#8220;<tt>anotherUrl</tt>&#8220;.  This is a little different from some other JSP mechanisms we will come across, for including another page or forwarding the browser to another page.</p>
<p><em>Exercise:</em> Write a JSP to output the entire line, &#8220;Hello!  The time is now &#8230;&#8221; but use a scriptlet for the complete string, including the HTML tags.</td>
</tr>
</tbody>
</table>
<h2>Mixing Scriptlets and HTML</h2>
<p>We have already seen how to use the &#8220;<tt>out</tt>&#8221; variable to generate HTML output from within a scriptlet.  For more complicated HTML, using the out variable all the time loses some of the advantages of JSP programming.  It is simpler to mix scriptlets and HTML.</p>
<p>Suppose you have to generate a table in HTML.  This is a common operation, and you may want to generate a table from a SQL table, or from the lines of a file.  But to keep our example simple, we will generate a table containing the numbers from 1 to N.  Not very useful, but it will show you the technique.</p>
<p>Here is the JSP fragment to do it:</p>
<pre>&lt;TABLE BORDER=2&gt;&lt;%    for ( int i = 0; i &lt; n; i++ ) {        %&gt;        &lt;TR&gt;        &lt;TD&gt;Number&lt;/TD&gt;        &lt;TD&gt;&lt;%= i+1 %&gt;&lt;/TD&gt;        &lt;/TR&gt;        &lt;%    }%&gt;&lt;/TABLE&gt;</pre>
<p>You would have to supply an <tt>int</tt> variable &#8220;n&#8221; before it will work, and then it will output a simple table with &#8220;n&#8221; rows.</p>
<p>The important things to notice are how the <tt>%&gt;</tt> and <tt>&lt;%</tt> characters appear in the middle of the &#8220;<tt>for</tt>&#8221; loop, to let you drop back into HTML and then to come back to the scriptlet.</p>
<p>The concepts are simple here &#8212; as you can see, you can drop out of the scriptlets, write normal HTML, and get back into the scriptlet.  Any control expressions such as a &#8220;while&#8221; or a &#8220;for&#8221; loop or an &#8220;if&#8221; expression will control the HTML also.  If the HTML is inside a loop, it will be emitted once for each iteration of the loop.</p>
<p>Another example of mixing scriptlets and HTML is shown below &#8212; here it is assumed that there is a boolean variable named &#8220;<tt>hello</tt>&#8221; available.  If you set it to true, you will see one output, if you set it to false, you will see another output.</p>
<pre>&lt;%    if ( hello ) {        %&gt;        &lt;P&gt;Hello, world        &lt;%    } else {        %&gt;        &lt;P&gt;Goodbye, world        &lt;%    }%&gt;</pre>
<p>It is a little difficult to keep track of all open braces and scriptlet start and ends, but with a little practice and some good formatting discipline, you will acquire competence in doing it.</p>
<p><em>Exercise:</em> Make the above examples work.  Write a JSP to output all the values returned by <tt>System.getProperties</tt> with &#8220;&lt;BR&gt;&#8221; embedded after each property name and value.  Do not output the &#8220;&lt;BR&gt;&#8221; using the &#8220;out&#8221; variable.</p>
<h2>JSP Directives</h2>
<p>We have been fully qualifying the <tt>java.util.Date</tt> in the examples in the previous sections.  Perhaps you wondered why we don&#8217;t just import java.util.*;</p>
<p>It is possible to use &#8220;<tt>import</tt>&#8221; statements in JSPs, but the syntax is a little different from normal Java.  Try the following example:</p>
<pre>&lt;%@ page import="java.util.*" %&gt;&lt;HTML&gt;&lt;BODY&gt;&lt;%    System.out.println( "Evaluating date now" );    Date date = new Date();%&gt;Hello!  The time is now &lt;%= date %&gt;&lt;/BODY&gt;&lt;/HTML&gt;</pre>
<p>The first line in the above example is called a &#8220;directive&#8221;.  A JSP &#8220;directive&#8221; starts with <tt>&lt;%@</tt> characters.</p>
<p>This one is a &#8220;page directive&#8221;.  The page directive can contain the list of all imported packages.  To import more than one item, separate the package names by commas, e.g.</p>
<pre>&lt;%@ page import="java.util.*,java.text.*" %&gt;</pre>
<p>There are a number of JSP directives, besides the page directive.  Besides the page directives, the other most useful directives are include and taglib.  We will be covering taglib separately.</p>
<p>The include directive is used to physically include the contents of another file.  The included file can be HTML or JSP or anything else &#8212; the result is as if the original JSP file actually contained the included text.  To see this directive in action, create a new JSP</p>
<pre>&lt;HTML&gt;&lt;BODY&gt;Going to include hello.jsp...&lt;BR&gt;&lt;%@ include file="hello.jsp" %&gt;&lt;/BODY&gt;&lt;/HTML&gt;</pre>
<p>View this JSP in your browser, and you will see your original <tt>hello.jsp</tt> get included in the new JSP. <em>Exercise:</em> Modify all your earlier exercises to import the java.util packages.</p>
<h2>JSP Declarations</h2>
<p>The JSP you write turns into a class definition.  All the scriptlets you write are placed inside a single method of this class.</p>
<p>You can also add variable and method declarations to this class.  You can then use these variables and methods from your scriptlets and expressions.</p>
<p>To add a declaration, you must use the <strong><tt>&lt;%!</tt></strong> and <strong><tt>%&gt;</tt></strong> sequences to enclose your declarations, as shown below.</p>
<pre>&lt;%@ page import="java.util.*" %&gt;&lt;HTML&gt;&lt;BODY&gt;&lt;%!    Date theDate = new Date();    Date getDate()    {        System.out.println( "In getDate() method" );        return theDate;    }%&gt;Hello!  The time is now &lt;%= getDate() %&gt;&lt;/BODY&gt;&lt;/HTML&gt;</pre>
<p>The example has been created a little contrived, to show variable and method declarations.</p>
<p>Here we are declaring a Date variable <tt>theDate</tt>, and the method <tt>getDate</tt>.  Both of these are available now in our scriptlets and expressions.</p>
<p>But this example no longer works!  The date will be the same, no matter how often you reload the page.  This is because these are declarations, and will only be evaluated once when the page is loaded!  (Just as if you were creating a class and had variable initialization declared in it.)</p>
<p><em>Exercise:</em> Modify the above example to add another function <tt>computeDate</tt> which re-initializes <tt>theDate</tt>.  Add a scriptlet that calls <tt>computeDate</tt> each time.</p>
<p><strong>Note:</strong> Now that you know how to do this &#8212; it is in general not a good idea to use variables as shown here.  The JSP usually will run as multiple <em>threads</em> of one single instance.  Different threads would interfere with variable access, because it will be the same variable for all of them.  If you do have to use variables in JSP, you should use <em>synchronized</em> access, but that hurts the performance. In general, any data you need should go either in the <em>session</em> objet or the <em>request</em> objectc (these are introduced a little later) if passing data between different JSP pages.  Variables you declare inside <em>scriptlets</em> are fine, e.g. &lt;% int i = 45; %&gt; because these are declared inside the local scope and are not shared.</p>
<h2>JSP Tags</h2>
<p>Another important syntax element of JSP are tags.  JSP tags do not use <strong><tt>&lt;%</tt></strong>, but just the <strong><tt>&lt;</tt></strong> character.  A JSP tag is somewhat like an HTML tag.  JSP tags can have a &#8220;start tag&#8221;, a &#8220;tag body&#8221; and an &#8220;end tag&#8221;.  The start and end tag both use the tag name, enclosed in <tt>&lt;</tt> and <tt>&gt;</tt> characters.  The end starts with a <tt>/</tt> character after the <tt>&lt;</tt> character.  The tag names have an embedded colon character <tt>:</tt> in them, the part before the colon describes the type of the tag.  For instance:</p>
<pre>&lt;some:tag&gt;body&lt;/some:tag&gt;</pre>
<p>If the tag does not require a body, the start and end can be conveniently merged together, as</p>
<pre>&lt;some:tag/&gt;</pre>
<p>Here by closing the start tag with a /&gt; instead of &gt; character, we are ending the tag immediately, and without a body.  (This syntax convention is the the same as XML.)</p>
<p>Tags can be of two types: loaded from an external tag library, or predefined tags.   Predefined tags start with <strong><tt>jsp:</tt></strong> characters.  For instance, <tt>jsp:include</tt> is a predefined tag that is used to include other pages.</p>
<p>We have already seen the <tt>include</tt> directive.  jsp:include is similar.  But instead of loading the text of the included file in the original file, it actually calls the included target at run-time (the way a browser would call the included target.  In practice, this is actually a simulated request rather than a full round-trip between the browser and the server).  Following is an example of <tt>jsp:include</tt> usage</p>
<pre>&lt;HTML&gt;&lt;BODY&gt;Going to include hello.jsp...&lt;BR&gt;&lt;jsp:include page="hello.jsp"/&gt;&lt;/BODY&gt;&lt;/HTML&gt;</pre>
<p>Try it and see what you get.  Now change the &#8220;<tt>jsp:include</tt>&#8221; to &#8220;<tt>jsp:forward</tt>&#8221; and see what is the difference.  These two predefined tags are frequently very useful.</p>
<p><em>Exercise:</em> Write a JSP to do either a <tt>forward</tt> or an <tt>include</tt>, depending upon a boolean variable (hint:  The concepts of mixing HTML and scriptlets work with JSP tags also!)</p>
<h2>JSP Sessions</h2>
<p>On a typical web site, a visitor might visit several pages and perform several interactions.</p>
<p>If you are programming the site, it is very helpful to be able to associate some data with each visitor.  For this purpose, &#8220;<tt>session</tt>&#8220;s can be used in JSP.</p>
<p>A session is an object associated with a visitor.  Data can be put in the session and retrieved from it, much like a Hashtable.  A different set of data is kept for each visitor to the site.</p>
<p>Here is a set of pages that put a user&#8217;s name in the session, and display it elsewhere.  Try out installing and using these.</p>
<p>First we have a form, let us call it GetName.html</p>
<pre><tt>&lt;HTML&gt;&lt;BODY&gt;&lt;FORM METHOD=POST ACTION="SaveName.jsp"&gt;What's your name? &lt;INPUT TYPE=TEXT NAME=username SIZE=20&gt;&lt;P&gt;&lt;INPUT TYPE=SUBMIT&gt;&lt;/FORM&gt;&lt;/BODY&gt;&lt;/HTML&gt;</tt></pre>
<p>The target of the form is &#8220;SaveName.jsp&#8221;, which saves the user&#8217;s name in the session.  Note the variable  &#8220;<tt>session</tt>&#8220;.  This is another variable that is normally made available in JSPs, just like <tt>out</tt> and <tt>request</tt> variables.  (In the @page directive, you can indicate that you do not need sessions, in which case the &#8220;session&#8221; variable will not be made available.)</p>
<pre>&lt;%   String name = request.getParameter( "username" );   session.setAttribute( "theName", name );%&gt;&lt;HTML&gt;&lt;BODY&gt;&lt;A HREF="NextPage.jsp"&gt;Continue&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</pre>
<p>The SaveName.jsp saves the user&#8217;s name in the session, and puts a link to another page, NextPage.jsp.</p>
<p>NextPage.jsp shows how to retrieve the saved name.</p>
<pre>&lt;HTML&gt;&lt;BODY&gt;Hello, &lt;%= session.getAttribute( "theName" ) %&gt;&lt;/BODY&gt;&lt;/HTML&gt;</pre>
<p>If you bring up two different browsers (not different windows of the same browser), or run two browsers from two different machines, you can put one name in one browser and another name in another browser, and both names will be kept track of.</p>
<p>The session is kept around until a timeout period.  Then it is assumed the user is no longer visiting the site, and the session is discarded.</p>
<p><em>Exercise:</em> Add another attribute &#8220;age&#8221; to the above example.</p>
<h2>Beans and Form processing</h2>
<p>Forms are a very common method of interactions in web sites.  JSP makes forms processing specially easy.</p>
<p>The standard way of handling forms in JSP is to define a &#8220;bean&#8221;.  This is not a full Java bean.  You just need to define a class that has a field corresponding to each field in the form.  The class fields must have &#8220;setters&#8221; that match the names of the form fields.  For instance, let us modify our <tt>GetName.html</tt> to also collect email address and age.</p>
<p>The new version of <tt>GetName.html</tt> is</p>
<pre><tt>&lt;HTML&gt;&lt;BODY&gt;&lt;FORM METHOD=POST ACTION="SaveName.jsp"&gt;What's your name? &lt;INPUT TYPE=TEXT NAME=username SIZE=20&gt;&lt;BR&gt;What's your e-mail address? &lt;INPUT TYPE=TEXT NAME=email SIZE=20&gt;&lt;BR&gt;What's your age? &lt;INPUT TYPE=TEXT NAME=age SIZE=4&gt;&lt;P&gt;&lt;INPUT TYPE=SUBMIT&gt;&lt;/FORM&gt;&lt;/BODY&gt;&lt;/HTML&gt;</tt></pre>
<p>To collect this data, we define a Java class with fields &#8220;<tt>username</tt>&#8220;, &#8220;<tt>email</tt>&#8221; and &#8220;<tt>age</tt>&#8221; and we provide setter methods &#8220;<tt>setUsername</tt>&#8220;, &#8220;<tt>setEmail</tt>&#8221; and &#8220;<tt>setAge</tt>&#8220;, as shown.  A &#8220;setter&#8221; method is just a method that starts with &#8220;<tt>set</tt>&#8221; followed by the name of the field.  The first character of the field name is upper-cased.  So if the field is &#8220;<tt>email</tt>&#8220;, its &#8220;<tt>setter</tt>&#8221; method will be &#8220;<tt>setEmail</tt>&#8220;.  Getter methods are defined similarly, with &#8220;get&#8221; instead of &#8220;set&#8221;.   Note that the setters  (and getters) must be public.</p>
<pre><tt>package user;

public class UserData {</tt></pre>
<pre><tt>    String username;    String email;    int age;

    public void setUsername( String value )    {        username = value;    }

    public void setEmail( String value )    {        email = value;    }

    public void setAge( int value )    {        age = value;    }

    public String getUsername() { return username; }

    public String getEmail() { return email; }

    public int getAge() { return age; }</tt></pre>
<pre><tt>}</tt></pre>
<p>The method names must be exactly as shown.  Once you have defined the class, compile it and make sure it is available in the web-server&#8217;s classpath.  The server may also define special folders where you can place bean classes, e.g. with Blazix you can place them in the &#8220;<tt>classes</tt>&#8221; folder.  If you have to change the classpath, the web-server would need to be stopped and restarted if it is already running.  (If you are not familiar with setting/changing classpath, see <a href="http://www.jsptut.com/Classpath.html">notes on changing classpath</a>.)</p>
<p>Note that we are using the package name <tt>user</tt>, therefore the file <tt>UserData.class</tt> must be placed in a folder named <tt>user</tt> under the classpath entry.</p>
<p>Now let us change &#8220;<tt>SaveName.jsp</tt>&#8221; to use a bean to collect the data.</p>
<pre>&lt;jsp:useBean id="user" class="user.UserData" scope="session"/&gt;&lt;jsp:setProperty name="user" property="*"/&gt; &lt;HTML&gt;&lt;BODY&gt;&lt;A HREF="NextPage.jsp"&gt;Continue&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</pre>
<p>All we need to do now is to add the <tt>jsp:useBean</tt> tag and the <tt>jsp:setProperty</tt> tag!  The useBean tag will look for an instance of the &#8220;<tt>user.UserData</tt>&#8221; in the session.  If the instance is already there, it will update the old instance.  Otherwise, it will create a new instance of <tt>user.UserData</tt> (the instance of the <tt>user.UserData</tt> is called a bean), and put it in the session.</p>
<p>The setProperty tag will automatically collect the input data, match names against the bean method names, and place the data in the bean!</p>
<p>Let us modify <tt>NextPage.jsp</tt> to retrieve the data from bean..</p>
<pre>&lt;jsp:useBean id="user" class="user.UserData" scope="session"/&gt; &lt;HTML&gt;&lt;BODY&gt;You entered&lt;BR&gt;Name: &lt;%= user.getUsername() %&gt;&lt;BR&gt;Email: &lt;%= user.getEmail() %&gt;&lt;BR&gt;Age: &lt;%= user.getAge() %&gt;&lt;BR&gt;&lt;/BODY&gt;&lt;/HTML&gt;</pre>
<p>Notice that the same useBean tag is repeated.  The bean is available as the variable named &#8220;<tt>user</tt>&#8221; of class &#8220;<tt>user.UserData</tt>&#8220;.  The data entered by the user is all collected in the bean.</p>
<p>We do not actually need the &#8220;<tt>SaveName.jsp</tt>&#8220;, the target of <tt>GetName.html</tt> could have been <tt>NextPage.jsp</tt>, and the data would still be available the same way as long as we added a <tt>jsp:setProperty</tt> tag.  But in the next tutorial, we will actually use <tt>SaveName.jsp</tt> as an error handler that automatically forwards the request to <tt>NextPage.jsp</tt>, or asks the user to correct the erroneous data.</p>
<p><em>Exercise:</em> 1)  Write a JSP/HTML set that allows a user to enter the name of a system property, and then displays the value returned by <tt>System.getProperty</tt> for that property name (handle errors appripriately.)   2)  Go back to the exercises where you manually modified boolean variables.  Instead of a boolean variable, make these come from a HIDDEN form field that can be set to true or false.</p>
<h2>Tag libraries</h2>
<p>JSP 1.1 introduces a method of extending JSP tags, called &#8220;tag libraries&#8221;.  These libraries allow addition of tags similar to <tt>jsp:include</tt> or <tt>jsp:forward</tt>, but with different prefixes other than <tt>jsp:</tt> and with additional features.</p>
<p>To introduce you to tag libraries, in this tutorial we use the Blazix tag library as an example.  This tag library comes bundled with the <a href="http://www.blazix.com/blazixserver.html" target="_new">Blazix server</a>.  If you are not using the Blazix Server, you may just want to review the material to get familiar with the syntax, and continue on to the next page.</p>
<p>Each tag-library will have its own tag-library specific documentation.  In order to use the tag library, you use the &#8220;taglib&#8221; directive to specify where your tag library&#8217;s &#8220;description&#8221; resides.  For the Blazix tag library,  the (recommended) directive is as follows</p>
<pre><tt>&lt;%@ taglib prefix="blx" uri="/blx.tld" %&gt;</tt></pre>
<p>The &#8220;uri&#8221; specifies where to find the tag library description.   The &#8220;prefix&#8221; is unique for the tag library.  This directive is saying that we will be using the tags in this library by starting them with <strong><tt>blx:</tt></strong></p>
<p>The Blazix tag library provides a blx:getProperty tag.  This tag can be used to allow the user to edit form data.  In our GetName.jsp file, we will now add a jsp:useBean and place the form inside blx:getProperty.</p>
<p>The new GetName.jsp is</p>
<pre><tt>&lt;%@ taglib prefix="blx" uri="/blx.tld" %&gt;&lt;jsp:useBean id="user" class="user.UserData" scope="session"/&gt;&lt;HTML&gt;&lt;BODY&gt;&lt;blx:getProperty name="user" property="*"&gt;&lt;FORM METHOD=POST ACTION="SaveName.jsp"&gt;What's your name? &lt;INPUT TYPE=TEXT NAME=username SIZE=20&gt;&lt;BR&gt;What's your e-mail address? &lt;INPUT TYPE=TEXT NAME=email SIZE=20&gt;&lt;BR&gt;What's your age? &lt;INPUT TYPE=TEXT NAME=age SIZE=4&gt;&lt;P&gt;&lt;INPUT TYPE=SUBMIT&gt;&lt;/FORM&gt;&lt;/blx:getProperty&gt;&lt;/BODY&gt;&lt;/HTML&gt;</tt></pre>
<p>Note that the blx:getProperty doesn&#8217;t end with /&gt; but is instead terminated by a separate &lt;/blx:getProperty&gt; line.  This puts all the form input fields inside the blx:getProperty so they can be appropriately modified by the tag library.</p>
<p>Try putting a link to GetName.jsp from the NextPage.jsp, and you will see that the bean&#8217;s data shows up automatically in the input fields.</p>
<p>The user can now edit the data.</p>
<p>We still have a couple of problems.  The user cannot clear out the name field.  Moreover, if the user enters a bad item in the &#8220;age&#8221; field, something which is not a valid integer, a Java exception occurs.</p>
<p>We will use another tag from the Blazix tag library to take care of this.  Blazix offers a blx:setProperty tag that can be used to take care of these problems. <tt> blx:setProperty</tt> allows us to define an exception handler method.  If an exception occurs, we can collect an error message for the user and continue processing.</p>
<p>Following is a version of SaveName.jsp that processes any errors, and either shows the user GetName.jsp again to user can enter the data correctly, or automatically forwards to NextPage.jsp.</p>
<pre>&lt;%@ taglib prefix="blx" uri="/blx.tld" %&gt;&lt;%!    boolean haveError;    StringBuffer errors;

    public void errorHandler( String field,                              String value,                              Exception ex )    {        haveError = true;        if ( errors == null )            errors = new StringBuffer();        else            errors.append( "&lt;P&gt;" );        errors.append( "&lt;P&gt;Value for field \"" +                     field + "\" is invalid." );        if ( ex instanceof java.lang.NumberFormatException )            errors.append( " The value must be a number." );    }%&gt;&lt;%    // Variables must be initialized outside declaration!    haveError = false;    errors = null;%&gt;&lt;HTML&gt;&lt;BODY&gt;&lt;jsp:useBean id="user" class="user.UserData" scope="session"/&gt;&lt;blx:setProperty name="user"     property="*"      onError="errorHandler"/&gt; &lt;%    if ( haveError ) {        out.println( errors.toString());        pageContext.include( "GetName.jsp" );    } else        pageContext.forward( "NextPage.jsp" );%&gt;&lt;/BODY&gt;&lt;/HTML&gt;</pre>
<p>Note that <tt>haveError</tt> and <tt>errors</tt> must be re-initialized each time, therefore they are being initialized outside of the declaration.</p>
<p>[Also notice the use of <tt>pageContext.include</tt> and <tt>pageContext.forward</tt>.  These are like <tt>jsp:include</tt> and <tt>jsp:forward</tt>, but are more convenient to use from within Java blocks.   p<tt>ageContext</tt> is another pre-defined variable that makes it easy to do certain operations from within Java blocks.]</p>
<p>Here, if an error occurs during the processing of <tt>blx:setProperty</tt>, we display the error and then include the <tt>GetName.jsp</tt> again so user can correct the error.  If no errors occur, we automatically forward the user to <tt>NextPage.jsp</tt>.</p>
<p>There is still a problem with the forms, the &#8220;age&#8221; shows up as zero initially rather than being empty.  This can be fixed by adding &#8220;<tt>emptyInt=0"</tt> to both the <tt>blx:getProperty</tt> and <tt>blx:setProperty</tt> tags (bean fields should be initialized to 0.)   It happens that &#8220;0&#8243; is not a valid value for age, so we can use &#8220;0&#8243; to mark empty strings.  If &#8220;0&#8243; were a valid value for age, we could have added &#8220;<tt>emptyInt=-1</tt>&#8221; (and made sure to initialize the bean fields to -1.)</p>
<p>Another small problem is that the &#8220;&lt;HTML&gt;&#8221; tag gets doubled if there is an error and we end up including &#8220;GetName.jsp&#8221;.  A more elegant solution is to remove the out.println, and pass back the error as shown</p>
<pre>&lt;%    if ( haveError ) {        request.setAttribute( "errors",                 errors.toString());        pageContext.forward( "GetName.jsp" );    } else        pageContext.forward( "NextPage.jsp" );%&gt;</pre>
<p>We can then do a &#8220;<tt>request.getAttribute</tt>&#8221; in the <tt>GetName.jsp</tt>&lt;!&#8211; This is left as an exercise.</p>
<p><em>Exercise:</em> Read the documentation on Blazix or another tag library, and use some tags from this library. &#8211;&gt;, and if the returned value is non-null, display the error.</p>
<h2>Techniques for form editing</h2>
<p>A tag library such as the one that comes with the <a href="http://www.blazix.com/blazixserver.html" target="_new">Blazix server</a>, may not be available in your environment.  How can you allow similar features without using a tag library?</p>
<p>It is a little tedious, but it can be done.  Basically, you must edit each HTML tag yourself, and put in a default value.  The following examples shows how we modify GetName.jsp to provide features similar to <tt>blx:getProperty</tt> but with manual HTML tag editing:</p>
<pre><tt>&lt;jsp:useBean id="user" class="user.UserData" scope="session"/&gt;&lt;HTML&gt;&lt;BODY&gt;&lt;FORM METHOD=POST ACTION="SaveName.jsp"&gt;What's your name? &lt;INPUT TYPE=TEXT NAME=username         SIZE=20 VALUE="&lt;%= user.getUsername() %&gt;"&gt;&lt;BR&gt;What's your e-mail address? &lt;INPUT TYPE=TEXT         NAME=email SIZE=20         VALUE="&lt;%= user.getEmail() %&gt;"&gt;&lt;BR&gt;What's your age? &lt;INPUT TYPE=TEXT NAME=age         SIZE=4 VALUE=&lt;%= user.getAge() %&gt;&gt;&lt;P&gt;&lt;INPUT TYPE=SUBMIT&gt;&lt;/FORM&gt;&lt;/BODY&gt;&lt;/HTML&gt;</tt></pre>
<p>As you can see, this simply involves adding a &#8220;VALUE&#8221; field in the INPUT tags, and initializing the field with an expression! To handle exceptions during input processing, a simple approach is to use &#8220;<tt>String</tt>&#8221; fields in the bean, and do the conversion to the target datatype yourself.  This will allow you to handle exceptions.</p>
<h2>Protecting your website with a login page</h2>
<p>Some sites require that all users log-in using a username and password, before being able to visit any page.</p>
<p>This can be done using JSP sessions or servlets, and in fact this was a common technique for a while.  But starting with a new release of Servlets specifications (2.2) from Sun, this feature is now very simple to implement.</p>
<p>It is no longer necessary to use JSP techniques to provide login/password protection, but it is still a very common requirement of web-sites, therefore a brief overview is provided here.</p>
<p>To password-protect your site, you just need to design a login page.  This page can be as simple or complicated as you need it to be.  It must contain a <tt>&lt;FORM&gt;</tt> tag, with the <tt>METHOD</tt> set to <tt>POST</tt> and the <tt>ACTION</tt> set to &#8220;<tt>j_security_check</tt>&#8220;.</p>
<p><tt>&lt;FORM METHOD=POST ACTION=j_security_check&gt;</tt></p>
<p>The target <tt>j_security_check</tt> is provided by the application server, and does not need to be coded.</p>
<p>The form must contain two <tt>&lt;INPUT&gt;</tt> fields, named <tt>j_username</tt> and <tt>j_password</tt> respectively for the username and password.  Typically, the username field will be a <tt>TEXT</tt> input field, and the password field will be a <tt>PASSWORD</tt> input field.</p>
<p>After this, you must tell your application server to password protect your pages using the login page you have provided.  The details will vary from server to server, but a good implementation will provide you hooks that you can use, for example, to match usernames and passwords against a database.  (E.g., in Blazix you can supply an implementation of the interface <tt>desisoft.deploy.AuthCheck</tt> to check usernames and passwords against a database or other sources.)</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sssbharathi.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sssbharathi.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sssbharathi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sssbharathi.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sssbharathi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sssbharathi.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sssbharathi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sssbharathi.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sssbharathi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sssbharathi.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sssbharathi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sssbharathi.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sssbharathi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sssbharathi.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sssbharathi.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sssbharathi.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sssbharathi.wordpress.com&amp;blog=3748082&amp;post=3&amp;subd=sssbharathi&amp;ref=&amp;feed=1" width="1" height="1" /><div class="sharedaddy"></div>]]></content:encoded>
			<wfw:commentRss>http://sssbharathi.wordpress.com/2008/05/17/jsp-tutorial/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/760fbb9669281633d0dce00548cee740?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sssbharathi</media:title>
		</media:content>
	</item>
	</channel>
</rss>
