<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Mahol Dot Org</title>
	
	<link>http://www.mahol.org/blog</link>
	<description>Weblog For All Your Need</description>
	<lastBuildDate>Thu, 17 May 2012 16:56:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/MaholDotOrg" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="maholdotorg" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">MaholDotOrg</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Basic Servlet Attributes Thread Safety Interview Questions Answers Explained</title>
		<link>http://www.mahol.org/blog/basic-servlet-attributes-thread-safety-interview-questions-answers-explained/</link>
		<comments>http://www.mahol.org/blog/basic-servlet-attributes-thread-safety-interview-questions-answers-explained/#comments</comments>
		<pubDate>Tue, 15 May 2012 11:33:18 +0000</pubDate>
		<dc:creator>asitkr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[OPPS]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Tech-Tips]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[attributes]]></category>
		<category><![CDATA[getAttribute()]]></category>
		<category><![CDATA[getServletContext()]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[request]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[setAttribute().getSession()]]></category>

		<guid isPermaLink="false">http://www.mahol.org/blog/?p=911</guid>
		<description><![CDATA[Servlet Attributes Thread Safety   An attribute is used to communicate some value from one servlet to another. Depending upon the scope of the attribute we can access the attributes at parts of the application.An attribute can be set at either of the scopes as follows : 1.Application 2.Session 3.Request &#160; Now in order to [...]


Related posts:<ol><li><a href='http://www.mahol.org/blog/types-of-attributes-in-servlet-servlet-scopes-and-attributes-saving-data-in-a-servlet-attributes-interview-question/' rel='bookmark' title='Permanent Link: Types Of Attributes In Servlet Servlet Scopes And Attributes Saving Data In A Servlet Attributes Interview Question'>Types Of Attributes In Servlet Servlet Scopes And Attributes Saving Data In A Servlet Attributes Interview Question</a></li>
<li><a href='http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/' rel='bookmark' title='Permanent Link: Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming'>Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming</a></li>
<li><a href='http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/' rel='bookmark' title='Permanent Link: How Container Does The Cookie Work in J2EE Define Cookie Cookies Explained Session In Servlet What Is Cookie How Apache Tomcat Handles Cookies Cookies Explained How Cookies Work Cookie Guide'>How Container Does The Cookie Work in J2EE Define Cookie Cookies Explained Session In Servlet What Is Cookie How Apache Tomcat Handles Cookies Cookies Explained How Cookies Work Cookie Guide</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Servlet Attributes Thread Safety  </strong></p>
<p>An attribute is used to communicate some value from one servlet to another. Depending upon the scope of the attribute we can access the attributes at parts of the application.An attribute can be set at either of the scopes as follows :</p>
<p><strong>1.</strong><strong>Application</strong><strong></strong></p>
<p><strong>2.Session</strong></p>
<p><strong>3.</strong><strong>Request</strong></p>
<p>&nbsp;</p>
<p>Now in order to find out which attribute/s is/are thread safe,we can ponder upon with following discussion.</p>
<p><strong>1.Application Attributes :</strong> An <strong>application attribute</strong> is a value set at application level. The code to set the attribute at application level is :</p>
<p>getServletContext().setAttribute(“name”,”value”);</p>
<p>As these attributes are accessible throughout the application,any servlet or any other web entity can update or get these attributes from various parts of the application. Since application attributes can be accessed or modified by any servlet in the web application,these are not thread safe.</p>
<p>&nbsp;</p>
<p><strong>2.Session Attributes :</strong> A <strong>session attribute</strong> is a value set at session scope. Session is used to retain user specific data. The code to set the attribute at application level is :</p>
<p>req.getSession().setAttribute(“name”,”value”);</p>
<p>When we talk about thread safety of session attributes,at one glimpse it deceives to appear as thread safe. In cases where we have the new tab feature in the modern browsers,the same session for the web application is opened in the new tab. In such case, if session attribute are updated from one tab will be reflected in the another tab with the same session. Thus we can say that session attributes are also not thread safe.</p>
<p><strong>3.Request Attributes :</strong> A <strong>request attribute</strong> is a value set at request scope.he code to set the attribute at application scope is :</p>
<p>req.setAttribute(“name”,”value”);</p>
<p>As we know that each request is a unique object , whatever attribute we set at request scope cant be updated or get from another request. Thus request attributes are thread safe.</p>
<p><strong>Conclusion : Thus request attributes are thread safe and application and session attributes are not.</strong></p>
Number of View :16

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mahol.org/blog/basic-servlet-attributes-thread-safety-interview-questions-answers-explained/&amp;title=Basic+Servlet+Attributes+Thread+Safety+Interview+Questions+Answers+Explained" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Basic+Servlet+Attributes+Thread+Safety+Interview+Questions+Answers+Explained+-+http://tinyurl.com/6shn2oz&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mahol.org/blog/basic-servlet-attributes-thread-safety-interview-questions-answers-explained/&amp;t=Basic+Servlet+Attributes+Thread+Safety+Interview+Questions+Answers+Explained" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mahol.org/blog/basic-servlet-attributes-thread-safety-interview-questions-answers-explained/&amp;submitHeadline=Basic+Servlet+Attributes+Thread+Safety+Interview+Questions+Answers+Explained&amp;submitSummary=Servlet%20Attributes%20Thread%20Safety%20%C2%A0%0D%0A%0D%0AAn%20attribute%20is%20used%20to%20communicate%20some%20value%20from%20one%20servlet%20to%20another.%20Depending%20upon%20the%20scope%20of%20the%20attribute%20we%20can%20access%20the%20attributes%20at%20parts%20of%20the%20application.An%20attribute%20can%20be%20set%20at%20either%20of%20the%20scopes%20as%20follows%20%3A%0D%0A%0D%0A1.Application%0D%0A%0D%0A2.Ses&amp;submitCategory=world_news&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mahol.org/blog/basic-servlet-attributes-thread-safety-interview-questions-answers-explained/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.mahol.org/blog/basic-servlet-attributes-thread-safety-interview-questions-answers-explained/&amp;title=Basic+Servlet+Attributes+Thread+Safety+Interview+Questions+Answers+Explained" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.mahol.org/blog/types-of-attributes-in-servlet-servlet-scopes-and-attributes-saving-data-in-a-servlet-attributes-interview-question/' rel='bookmark' title='Permanent Link: Types Of Attributes In Servlet Servlet Scopes And Attributes Saving Data In A Servlet Attributes Interview Question'>Types Of Attributes In Servlet Servlet Scopes And Attributes Saving Data In A Servlet Attributes Interview Question</a></li>
<li><a href='http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/' rel='bookmark' title='Permanent Link: Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming'>Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming</a></li>
<li><a href='http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/' rel='bookmark' title='Permanent Link: How Container Does The Cookie Work in J2EE Define Cookie Cookies Explained Session In Servlet What Is Cookie How Apache Tomcat Handles Cookies Cookies Explained How Cookies Work Cookie Guide'>How Container Does The Cookie Work in J2EE Define Cookie Cookies Explained Session In Servlet What Is Cookie How Apache Tomcat Handles Cookies Cookies Explained How Cookies Work Cookie Guide</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mahol.org/blog/basic-servlet-attributes-thread-safety-interview-questions-answers-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Types Of Attributes In Servlet Servlet Scopes And Attributes Saving Data In A Servlet Attributes Interview Question</title>
		<link>http://www.mahol.org/blog/types-of-attributes-in-servlet-servlet-scopes-and-attributes-saving-data-in-a-servlet-attributes-interview-question/</link>
		<comments>http://www.mahol.org/blog/types-of-attributes-in-servlet-servlet-scopes-and-attributes-saving-data-in-a-servlet-attributes-interview-question/#comments</comments>
		<pubDate>Mon, 14 May 2012 16:28:02 +0000</pubDate>
		<dc:creator>asitkr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[OPPS]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Tech-Tips]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[attributes]]></category>
		<category><![CDATA[getAttribute()]]></category>
		<category><![CDATA[getServletContext()]]></category>
		<category><![CDATA[getSession()]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[request]]></category>
		<category><![CDATA[scopes]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[setAttribute()]]></category>
		<category><![CDATA[web application]]></category>

		<guid isPermaLink="false">http://www.mahol.org/blog/?p=900</guid>
		<description><![CDATA[Types Of Attributes In Servlet &#160; An attribute is an object used to pass some value from one servlet to another.An attribute in a servlet can be set at various scopes depending upon the visibility in the web application.As we know that there are three scopes at servlet level in the application.Theses scopes are : [...]


Related posts:<ol><li><a href='http://www.mahol.org/blog/difference-between-parameters-and-attributes-in-servletsjsp-parameter-vs-attribute/' rel='bookmark' title='Permanent Link: Difference Between Parameters And Attributes In Servlets/JSP Parameter vs. Attribute'>Difference Between Parameters And Attributes In Servlets/JSP Parameter vs. Attribute</a></li>
<li><a href='http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/' rel='bookmark' title='Permanent Link: Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming'>Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming</a></li>
<li><a href='http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/' rel='bookmark' title='Permanent Link: Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking'>Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Types Of Attributes In Servlet</strong></p>
<p>&nbsp;</p>
<p>An attribute is an object used to pass some value from one servlet to another.An attribute in a servlet can be set at various scopes depending upon the visibility in the web application.As we know that there are three scopes at servlet level in the application.Theses scopes are :</p>
<p>1.Request</p>
<p>2.Session</p>
<p>3.Application</p>
<p>An attribute can be set on either of the scopes depending on the situation we want access the attribute value either at request,session or application level.</p>
<p>When we want the value of an attribute o be accessed at request level we use request attributes and likewise for session and application.</p>
<p>Types of attributes in servlet can be explained on the basis of scope it belongs to :</p>
<p>1.Request Attributes</p>
<p>2.Session attributes</p>
<p>3.Application Attributes</p>
<p>&nbsp;</p>
<p>1.Request Attributes can be set or get as demonstrated below in the code :</p>
<pre class="brush:java">req.setAttribute("name","value");
req.getAttribute("name");</pre>
<p>2.Session Attributes  can be set or get as shown below :</p>
<pre class="brush:java">req.getSession(false).setAttribute("name","value");
req.getSession(false).getAttribute("name");</pre>
<p>3.Application Attributes can be set or get as below :</p>
<pre class="brush:java">getServletContext().setAttribute("name","value");
getServletContext().getAttribute("name");</pre>
<p>Now comes the question where to use what?</p>
<p>Request Attributes : If we want to retain or communicate  a value across servlets where request does not change,we use request attributes.This can be the situation where include or forward is happening between the servlets in a web application.In such cases where we want to communicate a value across servlets we can use request attributes which when set from one servlet can be get in other servlets.</p>
<p>Session Attributes : In cases where user specific data has to be retained or communicated, we use session attributes.We use session attributes when we do not want a user&#8217;s data to be interfered by other users.It should be noted that these attributes can be retrieved  even when redirect is happening provided the session is maintained .</p>
<p>&nbsp;</p>
<p>Application Attributes : In cases where some value has to be set at application level and all the entities in the web application can read that value we use application attributes.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
Number of View :19

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mahol.org/blog/types-of-attributes-in-servlet-servlet-scopes-and-attributes-saving-data-in-a-servlet-attributes-interview-question/&amp;title=Types+Of+Attributes+In+Servlet+Servlet+Scopes+And+Attributes+Saving+Data+In+A+Servlet+Attributes+Interview+Question" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Types+Of+Attributes+In+Servlet+Servlet+Scopes+And+Attributes+Saving+Data+In+A+Se%5B..%5D+-+http://tinyurl.com/bup333b&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mahol.org/blog/types-of-attributes-in-servlet-servlet-scopes-and-attributes-saving-data-in-a-servlet-attributes-interview-question/&amp;t=Types+Of+Attributes+In+Servlet+Servlet+Scopes+And+Attributes+Saving+Data+In+A+Servlet+Attributes+Interview+Question" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mahol.org/blog/types-of-attributes-in-servlet-servlet-scopes-and-attributes-saving-data-in-a-servlet-attributes-interview-question/&amp;submitHeadline=Types+Of+Attributes+In+Servlet+Servlet+Scopes+And+Attributes+Saving+Data+In+A+Servlet+Attributes+Interview+Question&amp;submitSummary=Types%20Of%20Attributes%20In%20Servlet%0D%0A%0D%0A%26nbsp%3B%0D%0A%0D%0AAn%20attribute%20is%20an%20object%20used%20to%20pass%20some%20value%20from%20one%20servlet%20to%20another.An%20attribute%20in%20a%20servlet%20can%20be%20set%20at%20various%20scopes%20depending%20upon%20the%20visibility%20in%20the%20web%20application.As%20we%20know%20that%20there%20are%20three%20scopes%20at%20servlet%20level%20in%20the%20applica&amp;submitCategory=world_news&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mahol.org/blog/types-of-attributes-in-servlet-servlet-scopes-and-attributes-saving-data-in-a-servlet-attributes-interview-question/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.mahol.org/blog/types-of-attributes-in-servlet-servlet-scopes-and-attributes-saving-data-in-a-servlet-attributes-interview-question/&amp;title=Types+Of+Attributes+In+Servlet+Servlet+Scopes+And+Attributes+Saving+Data+In+A+Servlet+Attributes+Interview+Question" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.mahol.org/blog/difference-between-parameters-and-attributes-in-servletsjsp-parameter-vs-attribute/' rel='bookmark' title='Permanent Link: Difference Between Parameters And Attributes In Servlets/JSP Parameter vs. Attribute'>Difference Between Parameters And Attributes In Servlets/JSP Parameter vs. Attribute</a></li>
<li><a href='http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/' rel='bookmark' title='Permanent Link: Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming'>Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming</a></li>
<li><a href='http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/' rel='bookmark' title='Permanent Link: Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking'>Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mahol.org/blog/types-of-attributes-in-servlet-servlet-scopes-and-attributes-saving-data-in-a-servlet-attributes-interview-question/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Difference Between Abstract Class And Interface In Java Abstract Class Vs Interface When To Use An Abstract Class And An Interface</title>
		<link>http://www.mahol.org/blog/difference-between-abstract-class-and-interface-in-java/</link>
		<comments>http://www.mahol.org/blog/difference-between-abstract-class-and-interface-in-java/#comments</comments>
		<pubDate>Sun, 13 May 2012 19:25:12 +0000</pubDate>
		<dc:creator>asitkr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[OPPS]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Tech-Tips]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[abstract class]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.mahol.org/blog/?p=888</guid>
		<description><![CDATA[Difference Between Abstract Class And Interface In Java &#160; An abstract class in java is a class which has at least one abstract function. An interface in java  is an entity and not a class which has all its methods as abstract.We cannot have even one implementation of function or method in an interface in [...]


Related posts:<ol><li><a href='http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/' rel='bookmark' title='Permanent Link: Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming'>Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming</a></li>
<li><a href='http://www.mahol.org/blog/quartz-open-source-scheduler-basic-schedulers-in-java-install-quartz-for-java/' rel='bookmark' title='Permanent Link: Quartz Open source Scheduler Basic Schedulers in Java Install Quartz for JAva'>Quartz Open source Scheduler Basic Schedulers in Java Install Quartz for JAva</a></li>
<li><a href='http://www.mahol.org/blog/difference-between-parameters-and-attributes-in-servletsjsp-parameter-vs-attribute/' rel='bookmark' title='Permanent Link: Difference Between Parameters And Attributes In Servlets/JSP Parameter vs. Attribute'>Difference Between Parameters And Attributes In Servlets/JSP Parameter vs. Attribute</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Difference Between Abstract Class And Interface In Java</strong></p>
<p>&nbsp;</p>
<p>An abstract class in java is a class which has at least one abstract function.</p>
<p>An interface in java  is an entity and not a class which has all its methods as abstract.We cannot have even one implementation of function or method in an interface in java.</p>
<p>An abstract class with all its methods as abstract is close to being an interface.But the concept for usage of both is polls apart in context.</p>
<p>An abstract class looks like :</p>
<pre class="brush:java">public abstract class AbstractClassExample1{
abstract void abstractMethod();
// concrete methods are still allowed in abstract classes
void nonAbstractMethod() {
System.out.println("This is a non abstract method.");
}</pre>
<p>Here we can see that we can have both abstract and non abstract methods in abstract class.</p>
<p>An interface looks like :</p>
<pre class="brush:java">interface InterfaceExample{

  public void method1();
  public void method2();
  }
}</pre>
<p>&nbsp;</p>
<p>Here in the interface all the methods or functions are abstract.</p>
<p>All the methods in interface need to be public .</p>
<p>Now comes the scenario ,when to use an abstract class and when to use an interface.</p>
<p>Scenarios where we want re usability of some of the methods or functions and some methods or functions are left  for the client to implement as per their requirement calls for the use of an abstract class.In such cases client knows that some of the default implementation is already there and some part is up to them how to implement in the form of methods or functions.In such cases it logical to extend the concrete class from an abstract class.</p>
<p>Now comes the scenario where two coders are working for an application or software in which one calls the function or method  in his module which is written by another coder.If in future the first coder who writes the method or function ,for some reason changes the function signature it will hamper the code of the coder who is calling the function.To avoid these type of issues we can use interfaces.If the person who writes the method implements it with interface and the function call is also done with the reference type interlace,then both he coders know the standard to be followed in order to write or call a method.Thus in order to follow some standard we use interfaces.</p>
Number of View :23

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mahol.org/blog/difference-between-abstract-class-and-interface-in-java/&amp;title=Difference+Between+Abstract+Class+And+Interface+In+Java+Abstract+Class+Vs+Interface+When+To+Use+An+Abstract+Class+And+An+Interface" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Difference+Between+Abstract+Class+And+Interface+In+Java+Abstract+Class+Vs+Interf%5B..%5D+-+http://tinyurl.com/7hd35n2&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mahol.org/blog/difference-between-abstract-class-and-interface-in-java/&amp;t=Difference+Between+Abstract+Class+And+Interface+In+Java+Abstract+Class+Vs+Interface+When+To+Use+An+Abstract+Class+And+An+Interface" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mahol.org/blog/difference-between-abstract-class-and-interface-in-java/&amp;submitHeadline=Difference+Between+Abstract+Class+And+Interface+In+Java+Abstract+Class+Vs+Interface+When+To+Use+An+Abstract+Class+And+An+Interface&amp;submitSummary=Difference%20Between%20Abstract%20Class%20And%20Interface%20In%20Java%0D%0A%0D%0A%26nbsp%3B%0D%0A%0D%0AAn%20abstract%20class%20in%20java%20is%20a%20class%20which%20has%20at%20least%20one%20abstract%20function.%0D%0A%0D%0AAn%20interface%20in%20java%C2%A0%20is%20an%20entity%20and%20not%20a%20class%20which%20has%20all%20its%20methods%20as%20abstract.We%20cannot%20have%20even%20one%20implementation%20of%20function%20or%20metho&amp;submitCategory=world_news&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mahol.org/blog/difference-between-abstract-class-and-interface-in-java/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.mahol.org/blog/difference-between-abstract-class-and-interface-in-java/&amp;title=Difference+Between+Abstract+Class+And+Interface+In+Java+Abstract+Class+Vs+Interface+When+To+Use+An+Abstract+Class+And+An+Interface" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/' rel='bookmark' title='Permanent Link: Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming'>Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming</a></li>
<li><a href='http://www.mahol.org/blog/quartz-open-source-scheduler-basic-schedulers-in-java-install-quartz-for-java/' rel='bookmark' title='Permanent Link: Quartz Open source Scheduler Basic Schedulers in Java Install Quartz for JAva'>Quartz Open source Scheduler Basic Schedulers in Java Install Quartz for JAva</a></li>
<li><a href='http://www.mahol.org/blog/difference-between-parameters-and-attributes-in-servletsjsp-parameter-vs-attribute/' rel='bookmark' title='Permanent Link: Difference Between Parameters And Attributes In Servlets/JSP Parameter vs. Attribute'>Difference Between Parameters And Attributes In Servlets/JSP Parameter vs. Attribute</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mahol.org/blog/difference-between-abstract-class-and-interface-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Statements In JDBC JDBC Interview Questions JDBC Statements PreparedStatement and CallableStatement JDBC Technology Call Stored Procedures</title>
		<link>http://www.mahol.org/blog/statements-in-jdbc-jdbc-interview-questions-jdbc-statements-preparedstatement-and-callablestatement-jdbc-technology/</link>
		<comments>http://www.mahol.org/blog/statements-in-jdbc-jdbc-interview-questions-jdbc-statements-preparedstatement-and-callablestatement-jdbc-technology/#comments</comments>
		<pubDate>Sun, 13 May 2012 14:44:19 +0000</pubDate>
		<dc:creator>asitkr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[OPPS]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Tech-Tips]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[basics of jdbc]]></category>
		<category><![CDATA[callableStatement()]]></category>
		<category><![CDATA[class.forName()]]></category>
		<category><![CDATA[database connection]]></category>
		<category><![CDATA[driver class]]></category>
		<category><![CDATA[getConnection()]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[jdbc connection]]></category>
		<category><![CDATA[prepareStatement()]]></category>
		<category><![CDATA[statements]]></category>

		<guid isPermaLink="false">http://www.mahol.org/blog/?p=878</guid>
		<description><![CDATA[Statements In JDBC &#160; Statements  in JDBC are carrier for sql queries in JDBC.  Statements in JDBC are obtained from connection objects. Connection is the handle for the session between JDBC and Database server.Without connection object we cannot have a statement object and without statement object,sql queries cannot be run at the database server side [...]


Related posts:<ol><li><a href='http://www.mahol.org/blog/driver-registration-in-jdbc-jdbc-connecion-registering-the-jdbc-driver-registering-a-jdbc-driver-jdbc-database-connections-basics-of-jdbc-how-to-establish-a-jdbc-connection/' rel='bookmark' title='Permanent Link: Driver Registration In JDBC JDBC Connection Using the JDBC Driver Registering the JDBC driver Registering A JDBC driver JDBC Database Connections Basics Of JDBC  How To Establish A JDBC Connection'>Driver Registration In JDBC JDBC Connection Using the JDBC Driver Registering the JDBC driver Registering A JDBC driver JDBC Database Connections Basics Of JDBC  How To Establish A JDBC Connection</a></li>
<li><a href='http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/' rel='bookmark' title='Permanent Link: Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming'>Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming</a></li>
<li><a href='http://www.mahol.org/blog/transaction-locking-and-isolation-in-jdbc-transaction-isolation-levels-using-transactions-jdbc-isolation-example-jdbc-guide-basics-of-jdbc/' rel='bookmark' title='Permanent Link: Transaction Locking And Isolation In JDBC Transaction isolation levels Using Transactions JDBC Isolation Example JDBC Guide Basics Of JDBC'>Transaction Locking And Isolation In JDBC Transaction isolation levels Using Transactions JDBC Isolation Example JDBC Guide Basics Of JDBC</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Statements In JDBC</strong></p>
<p>&nbsp;</p>
<p>Statements  in JDBC are carrier for sql queries in JDBC.  Statements in JDBC are obtained from connection objects.</p>
<p>Connection is the handle for the session between JDBC and Database server.Without connection object we cannot have a statement object and without statement object,sql queries cannot be run at the database server side from the JDBC code.</p>
<p>There are three types of statements in JDBC.These are as follows :</p>
<p><strong>1.Statement</strong></p>
<p><strong>2.Prepared Statement</strong></p>
<p><strong>3.Callable Statement</strong></p>
<p>&nbsp;</p>
<p><strong>1.Statement :</strong> These statements are used to execute queries like select statements at the server side. Every time a statement is run it is compiled at the server (database side),it is compiled at the server side and run.</p>
<p>The code looks like this :</p>
<pre class="brush:java">Class.forName("driver class");
Connection conn = DriverManager.getConnection("connection string","username","password");
String sql = "select * from tablename";
Statement st  = conn.createStatement(sql);
st.executeQuery();</pre>
<p>&nbsp;</p>
<p><strong>2.Prepared Statement :</strong> These statements are used where we have to execute same query multiple number of times with small changes like update value.In such cases we do not need to compile the query again and again at the server side but we need to compile he query once and keep executing again and again at the the server side.Thus,prepared statements help in this case as these are precompiled statements which can be executed ample times thus saving time.</p>
<p>&nbsp;</p>
<p>The code looks like this :</p>
<pre class="brush:java">Class.forName("driver class");
Connection conn = DriverManager.getConnection("connection string","username","password");
String sql = "insert into tablename values (?,?,?)";
PreparedStatement pst  = conn.prepareStatement(sql);
pst.setString(1,"java");
pst.setInt(2,3);
pst.setFloat(3,3.14);
pst.executeQuery();</pre>
<p>&nbsp;</p>
<p>The &#8216;?&#8217; are placeholders to feed the value to the precompiled statements.setXXX methods are used to set the values to the placeholders depending upon the  data type at the server side.In the code pst.setString(1,&#8221;java&#8221;),1 denotes the first place holder.</p>
<p>&nbsp;</p>
<p><strong>3.Callable Statement :</strong> These statements are used to execute stored procedures and function at the database server side.</p>
<p>The code looks like this :</p>
<pre class="brush:java">Class.forName("driver class");
Connection conn = DriverManager.getConnection("connection string","username","password");
String sql = "{? = execute procesdureorfunctionname(?,?)}";
CallableStatement cst  = conn.prepareCall(sql);
cst.registerOutParameter(1,java.sql.Types.String);
cst.setString(2,"java");
cst.setInt(3,3);

cst.execute();
String str = cst.getString(1);</pre>
<p>&nbsp;</p>
Number of View :15

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mahol.org/blog/statements-in-jdbc-jdbc-interview-questions-jdbc-statements-preparedstatement-and-callablestatement-jdbc-technology/&amp;title=Statements+In+JDBC+JDBC+Interview+Questions+JDBC+Statements+PreparedStatement+and+CallableStatement+JDBC+Technology+Call+Stored+Procedures" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Statements+In+JDBC+JDBC+Interview+Questions+JDBC+Statements+PreparedStatement+an%5B..%5D+-+http://tinyurl.com/6v55fsc&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mahol.org/blog/statements-in-jdbc-jdbc-interview-questions-jdbc-statements-preparedstatement-and-callablestatement-jdbc-technology/&amp;t=Statements+In+JDBC+JDBC+Interview+Questions+JDBC+Statements+PreparedStatement+and+CallableStatement+JDBC+Technology+Call+Stored+Procedures" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mahol.org/blog/statements-in-jdbc-jdbc-interview-questions-jdbc-statements-preparedstatement-and-callablestatement-jdbc-technology/&amp;submitHeadline=Statements+In+JDBC+JDBC+Interview+Questions+JDBC+Statements+PreparedStatement+and+CallableStatement+JDBC+Technology+Call+Stored+Procedures&amp;submitSummary=Statements%20In%20JDBC%0D%0A%0D%0A%26nbsp%3B%0D%0A%0D%0AStatements%C2%A0%20in%20JDBC%20are%20carrier%20for%20sql%20queries%20in%20JDBC.%C2%A0%20Statements%20in%20JDBC%20are%20obtained%20from%20connection%20objects.%0D%0A%0D%0AConnection%20is%20the%20handle%20for%20the%20session%20between%20JDBC%20and%20Database%20server.Without%20connection%20object%20we%20cannot%20have%20a%20statement%20object%20and%20without%20st&amp;submitCategory=world_news&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mahol.org/blog/statements-in-jdbc-jdbc-interview-questions-jdbc-statements-preparedstatement-and-callablestatement-jdbc-technology/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.mahol.org/blog/statements-in-jdbc-jdbc-interview-questions-jdbc-statements-preparedstatement-and-callablestatement-jdbc-technology/&amp;title=Statements+In+JDBC+JDBC+Interview+Questions+JDBC+Statements+PreparedStatement+and+CallableStatement+JDBC+Technology+Call+Stored+Procedures" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.mahol.org/blog/driver-registration-in-jdbc-jdbc-connecion-registering-the-jdbc-driver-registering-a-jdbc-driver-jdbc-database-connections-basics-of-jdbc-how-to-establish-a-jdbc-connection/' rel='bookmark' title='Permanent Link: Driver Registration In JDBC JDBC Connection Using the JDBC Driver Registering the JDBC driver Registering A JDBC driver JDBC Database Connections Basics Of JDBC  How To Establish A JDBC Connection'>Driver Registration In JDBC JDBC Connection Using the JDBC Driver Registering the JDBC driver Registering A JDBC driver JDBC Database Connections Basics Of JDBC  How To Establish A JDBC Connection</a></li>
<li><a href='http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/' rel='bookmark' title='Permanent Link: Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming'>Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming</a></li>
<li><a href='http://www.mahol.org/blog/transaction-locking-and-isolation-in-jdbc-transaction-isolation-levels-using-transactions-jdbc-isolation-example-jdbc-guide-basics-of-jdbc/' rel='bookmark' title='Permanent Link: Transaction Locking And Isolation In JDBC Transaction isolation levels Using Transactions JDBC Isolation Example JDBC Guide Basics Of JDBC'>Transaction Locking And Isolation In JDBC Transaction isolation levels Using Transactions JDBC Isolation Example JDBC Guide Basics Of JDBC</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mahol.org/blog/statements-in-jdbc-jdbc-interview-questions-jdbc-statements-preparedstatement-and-callablestatement-jdbc-technology/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Life Cycle Of A Servlet Explained Handling Servlet Life-Cycle Events Servlet Life Cycle Servlet Interview Questions Java Servlet Programming</title>
		<link>http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/</link>
		<comments>http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/#comments</comments>
		<pubDate>Fri, 11 May 2012 11:40:44 +0000</pubDate>
		<dc:creator>asitkr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[OPPS]]></category>
		<category><![CDATA[Tech-Tips]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[apache tomcat server]]></category>
		<category><![CDATA[destroy]]></category>
		<category><![CDATA[init]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[life cycle]]></category>
		<category><![CDATA[oops]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[servlet config]]></category>

		<guid isPermaLink="false">http://www.mahol.org/blog/?p=873</guid>
		<description><![CDATA[Life Cycle Of A Servlet  A servlet is a java code which runs at the server side to process request and return response to the client. In other words, a servlet is an extension to the server which processes request and returns response as an HTML page to the client. Like applets we donot have [...]


Related posts:<ol><li><a href='http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/' rel='bookmark' title='Permanent Link: How Container Does The Cookie Work in J2EE Define Cookie Cookies Explained Session In Servlet What Is Cookie How Apache Tomcat Handles Cookies Cookies Explained How Cookies Work Cookie Guide'>How Container Does The Cookie Work in J2EE Define Cookie Cookies Explained Session In Servlet What Is Cookie How Apache Tomcat Handles Cookies Cookies Explained How Cookies Work Cookie Guide</a></li>
<li><a href='http://www.mahol.org/blog/eta-estimated-turn-around-time-planning-software-life-cycle/' rel='bookmark' title='Permanent Link: ETA &#8211; Estimated Turn Around Time Planning Software Life Cycle'>ETA &#8211; Estimated Turn Around Time Planning Software Life Cycle</a></li>
<li><a href='http://www.mahol.org/blog/a-hello-world-servlet-servlet-tutorial-servlet-examples/' rel='bookmark' title='Permanent Link: A Hello,World Servlet Servlet Tutorial Servlet Examples Run servlet on tomcat'>A Hello,World Servlet Servlet Tutorial Servlet Examples Run servlet on tomcat</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong><strong>Life Cycle Of A Servlet </strong></strong></p>
<p>A servlet is a java code which runs at the server side to process request and return response to the client.</p>
<p>In other words, a servlet is an extension to the server which processes request and returns response as an HTML page to the client. Like applets we donot have main method in a servlet. As in case of applet,its life cycle is taken care by the browser itself,similarly in case of servlet its life cycle of a servlet is managed by the server/container.</p>
<p>&nbsp;</p>
<p>Life Cycle Of A Servlet denotes the phases it goes through. These phases are symbolized by the life cycle methods in the servlet.As server manages the Life Cycle Of A Servlet, these life cycle methods are called by the server itself. Let us have a look at different Life Cycle methods Of A Servlet. These are as follows :</p>
<p>&nbsp;</p>
<ol>
<li><strong>init</strong></li>
<li><strong>service</strong></li>
<li><strong>destroy</strong></li>
</ol>
<p>&nbsp;</p>
<p><strong>1. init : </strong>The init method is the first Life Cycle method Of A Servlet. It is this method which after being called by the server makes a servlet eligible for being called a servlet. After the servlet class constructor is called,the init method is called by the server. The method looks like :</p>
<pre>public void init(ServletConfig sc) throws ServletException {
  // Initialization code...
}</pre>
<p>&nbsp;</p>
<p>Here we can see that the ServletConfig object is passed to the init method. This object is created by serverand passed to the init method. Having received the ServletConfig object ,a servlet is said to be a servlet.</p>
<p><strong>2. service</strong> : This life cycle method is called every time a request is sent to the servlet .This means that the servlet&#8217;s init method has been called and servlet is ready to process requests.This method looks like :</p>
<pre>public void service(ServletRequest request,
                    ServletResponse response)
      throws ServletException, IOException{
}</pre>
<p><strong>3.destroy : </strong>This is the last phase in the Life Cycle Of A Servlet. Before the servlet object is garbage collected at the server side this method is called to relinquish the resources at the server side. This method looks like :</p>
<pre>public void destroy() {
    // Finalization code...
  }</pre>
<p>It can be noted that the init method is called only once in the Life Cycle Of A Servlet, service is called as many times as many the requests are fired and destroy is called only once in the Life Cycle Of A Servlet.</p>
Number of View :36

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/&amp;title=Life+Cycle+Of+A+Servlet+Explained+Handling+Servlet+Life-Cycle+Events+Servlet+Life+Cycle+Servlet+Interview+Questions+Java+Servlet+Programming+" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Life+Cycle+Of+A+Servlet+Explained+Handling+Servlet+Life-Cycle+Events+Servlet+Lif%5B..%5D+-+http://tinyurl.com/8a3l28z&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/&amp;t=Life+Cycle+Of+A+Servlet+Explained+Handling+Servlet+Life-Cycle+Events+Servlet+Life+Cycle+Servlet+Interview+Questions+Java+Servlet+Programming+" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/&amp;submitHeadline=Life+Cycle+Of+A+Servlet+Explained+Handling+Servlet+Life-Cycle+Events+Servlet+Life+Cycle+Servlet+Interview+Questions+Java+Servlet+Programming+&amp;submitSummary=Life%20Cycle%20Of%20A%20Servlet%C2%A0%0D%0A%0D%0AA%20servlet%20is%20a%20java%20code%20which%20runs%20at%20the%20server%20side%20to%20process%20request%20and%20return%20response%20to%20the%20client.%0D%0A%0D%0AIn%20other%20words%2C%20a%20servlet%20is%20an%20extension%20to%20the%20server%20which%20processes%20request%20and%20returns%20response%20as%20an%20HTML%20page%20to%20the%20client.%20Like%20applets%20we%20donot%20have%20&amp;submitCategory=world_news&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/&amp;title=Life+Cycle+Of+A+Servlet+Explained+Handling+Servlet+Life-Cycle+Events+Servlet+Life+Cycle+Servlet+Interview+Questions+Java+Servlet+Programming+" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/' rel='bookmark' title='Permanent Link: How Container Does The Cookie Work in J2EE Define Cookie Cookies Explained Session In Servlet What Is Cookie How Apache Tomcat Handles Cookies Cookies Explained How Cookies Work Cookie Guide'>How Container Does The Cookie Work in J2EE Define Cookie Cookies Explained Session In Servlet What Is Cookie How Apache Tomcat Handles Cookies Cookies Explained How Cookies Work Cookie Guide</a></li>
<li><a href='http://www.mahol.org/blog/eta-estimated-turn-around-time-planning-software-life-cycle/' rel='bookmark' title='Permanent Link: ETA &#8211; Estimated Turn Around Time Planning Software Life Cycle'>ETA &#8211; Estimated Turn Around Time Planning Software Life Cycle</a></li>
<li><a href='http://www.mahol.org/blog/a-hello-world-servlet-servlet-tutorial-servlet-examples/' rel='bookmark' title='Permanent Link: A Hello,World Servlet Servlet Tutorial Servlet Examples Run servlet on tomcat'>A Hello,World Servlet Servlet Tutorial Servlet Examples Run servlet on tomcat</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mahol.org/blog/life-cycle-of-a-servlet-explained-handling-servlet-life-cycle-events-servlet-life-cycle-servlet-interview-questions-java-servlet-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Request Dispatching In Servlets Servlets / Request Dispatcher RequestDispatcher Vs SendRedirect What Is A Request Dispatcher And How Does It Work What Is A Request Dispatcher And How Do I Use It Include Forward Redirect</title>
		<link>http://www.mahol.org/blog/request-dispatching-in-servlets-servlets-request-dispatcher-requestdispatcher-vs-sendredirect-what-is-a-request-dispatcher-and-how-does-it-work-what-is-a-request-dispatcher-and-how-do-i-use-it-inclu/</link>
		<comments>http://www.mahol.org/blog/request-dispatching-in-servlets-servlets-request-dispatcher-requestdispatcher-vs-sendredirect-what-is-a-request-dispatcher-and-how-does-it-work-what-is-a-request-dispatcher-and-how-do-i-use-it-inclu/#comments</comments>
		<pubDate>Fri, 11 May 2012 10:11:47 +0000</pubDate>
		<dc:creator>asitkr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[OPPS]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Tech-Tips]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[forward]]></category>
		<category><![CDATA[include]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[request]]></category>
		<category><![CDATA[request dispatcher]]></category>
		<category><![CDATA[response]]></category>
		<category><![CDATA[servlet]]></category>

		<guid isPermaLink="false">http://www.mahol.org/blog/?p=866</guid>
		<description><![CDATA[Servlet Request Dispatching Delegating the request from one servlet to another or transfer of excution from one servlet to another is known as request dispatching in servlet. In another ways we can define it as interservlet communication,which means one servlet calling another servlet.This concept can be used in cases where some piece of code is [...]


Related posts:<ol><li><a href='http://www.mahol.org/blog/how-to-redirect-from-one-servlet-to-another-servlet-basics-servlet-redirect/' rel='bookmark' title='Permanent Link: How To Redirect From One Servlet To Another Servlet Basics Servlet Redirect'>How To Redirect From One Servlet To Another Servlet Basics Servlet Redirect</a></li>
<li><a href='http://www.mahol.org/blog/servletinclude/' rel='bookmark' title='Permanent Link: how to include one servlet into another  Servlet Essentials Servlet Include'>how to include one servlet into another  Servlet Essentials Servlet Include</a></li>
<li><a href='http://www.mahol.org/blog/how-to-forward-from-one-servlet-to-another-servlet-essentials-servlet-forward/' rel='bookmark' title='Permanent Link: how to forward from one servlet to another  Servlet Essentials Servlet Forward'>how to forward from one servlet to another  Servlet Essentials Servlet Forward</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Servlet Request Dispatching</strong></p>
<p>Delegating the request from one servlet to another or transfer of excution from one servlet to another is known as request dispatching in servlet.</p>
<p>In another ways we can define it as interservlet communication,which means one servlet calling another servlet.This concept can be used in cases where some piece of code is needed to be written in different servlets.Thus, in such cases we can write that code in a single servlet and keep on calling that code from different servlets.</p>
<p>There are three ways in which request delegation can be done. These ways are as follows :</p>
<p>&nbsp;</p>
<p>1.Include</p>
<p>2.Forward</p>
<p>3.Redirect</p>
<p>&nbsp;</p>
<p><strong>1.</strong> <strong>Include : </strong>This method suggests that the response from the another servlet be included in the response of the first  servlet. This is equivalent to copy pasting the response of one servlet into another.In case of inclusion,the response which the client receives is the append of both including and the included servlets.However,for the client it appears that the including servlet only has responded.Following line of code is used to include a servlet response into another servlet :</p>
<pre class="brush:java">RequestDispatcher rd = request.getRequestDispatcher("url-pattern of the servlet");
rd.include(request,response);</pre>
<p>&nbsp;</p>
<p>Here RequestDispatcher object is needed .We can see that request and response objects of the first servlet are passed to the servlet which we wish to include through include method so that request remains the same and the included servlet can write to the response of the including servlet and it appears that including servlet itself has processed the request.</p>
<p><strong>2. Forward :</strong> It works same as  include except for the difference that the reponse from the first servlet is flushed out and the reponse from the second servlet only is visible.Example code is :</p>
<pre class="brush:java">RequestDispatcher rd = request.getRequestDispatcher("url-pattern of the servlet");
rd.forward(request,response);</pre>
<p>&nbsp;</p>
<p>Here also it appears to the client that the first servlet only has processed the request.</p>
<p><strong>3. Redirect :</strong> In the case of redirect the first servlet issues a new request to a another servlet to which redirection has happened.In this case client sees a new request in the browser url bar and can realize that the response comes from the second servlet.Example code is :</p>
<pre class="brush:java">response.sendRedirect("url-pattern of the servlet");</pre>
<p>&nbsp;</p>
<p>Here we can see that response object is used.This done for the reason that the issuing of the new request at the client side,in the browser url bar has to be done by the first servlet.</p>
<p>&nbsp;</p>
Number of View :23

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mahol.org/blog/request-dispatching-in-servlets-servlets-request-dispatcher-requestdispatcher-vs-sendredirect-what-is-a-request-dispatcher-and-how-does-it-work-what-is-a-request-dispatcher-and-how-do-i-use-it-inclu/&amp;title=Request+Dispatching+In+Servlets+Servlets+%2F+Request+Dispatcher+RequestDispatcher+Vs+SendRedirect+What+Is+A+Request+Dispatcher+And+How+Does+It+Work+What+Is+A+Request+Dispatcher+And+How+Do+I+Use+It+Include+Forward+Redirect" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Request+Dispatching+In+Servlets+Servlets+%2F+Request+Dispatcher+RequestDispatcher+%5B..%5D+-+http://tinyurl.com/7os4p86&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mahol.org/blog/request-dispatching-in-servlets-servlets-request-dispatcher-requestdispatcher-vs-sendredirect-what-is-a-request-dispatcher-and-how-does-it-work-what-is-a-request-dispatcher-and-how-do-i-use-it-inclu/&amp;t=Request+Dispatching+In+Servlets+Servlets+%2F+Request+Dispatcher+RequestDispatcher+Vs+SendRedirect+What+Is+A+Request+Dispatcher+And+How+Does+It+Work+What+Is+A+Request+Dispatcher+And+How+Do+I+Use+It+Include+Forward+Redirect" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mahol.org/blog/request-dispatching-in-servlets-servlets-request-dispatcher-requestdispatcher-vs-sendredirect-what-is-a-request-dispatcher-and-how-does-it-work-what-is-a-request-dispatcher-and-how-do-i-use-it-inclu/&amp;submitHeadline=Request+Dispatching+In+Servlets+Servlets+%2F+Request+Dispatcher+RequestDispatcher+Vs+SendRedirect+What+Is+A+Request+Dispatcher+And+How+Does+It+Work+What+Is+A+Request+Dispatcher+And+How+Do+I+Use+It+Include+Forward+Redirect&amp;submitSummary=Servlet%20Request%20Dispatching%0D%0A%0D%0ADelegating%20the%20request%20from%20one%20servlet%20to%20another%20or%20transfer%20of%20excution%20from%20one%20servlet%20to%20another%20is%20known%20as%20request%20dispatching%20in%20servlet.%0D%0A%0D%0AIn%20another%20ways%20we%20can%20define%20it%20as%20interservlet%20communication%2Cwhich%20means%20one%20servlet%20calling%20another%20servlet.This%20con&amp;submitCategory=world_news&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mahol.org/blog/request-dispatching-in-servlets-servlets-request-dispatcher-requestdispatcher-vs-sendredirect-what-is-a-request-dispatcher-and-how-does-it-work-what-is-a-request-dispatcher-and-how-do-i-use-it-inclu/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.mahol.org/blog/request-dispatching-in-servlets-servlets-request-dispatcher-requestdispatcher-vs-sendredirect-what-is-a-request-dispatcher-and-how-does-it-work-what-is-a-request-dispatcher-and-how-do-i-use-it-inclu/&amp;title=Request+Dispatching+In+Servlets+Servlets+%2F+Request+Dispatcher+RequestDispatcher+Vs+SendRedirect+What+Is+A+Request+Dispatcher+And+How+Does+It+Work+What+Is+A+Request+Dispatcher+And+How+Do+I+Use+It+Include+Forward+Redirect" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.mahol.org/blog/how-to-redirect-from-one-servlet-to-another-servlet-basics-servlet-redirect/' rel='bookmark' title='Permanent Link: How To Redirect From One Servlet To Another Servlet Basics Servlet Redirect'>How To Redirect From One Servlet To Another Servlet Basics Servlet Redirect</a></li>
<li><a href='http://www.mahol.org/blog/servletinclude/' rel='bookmark' title='Permanent Link: how to include one servlet into another  Servlet Essentials Servlet Include'>how to include one servlet into another  Servlet Essentials Servlet Include</a></li>
<li><a href='http://www.mahol.org/blog/how-to-forward-from-one-servlet-to-another-servlet-essentials-servlet-forward/' rel='bookmark' title='Permanent Link: how to forward from one servlet to another  Servlet Essentials Servlet Forward'>how to forward from one servlet to another  Servlet Essentials Servlet Forward</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mahol.org/blog/request-dispatching-in-servlets-servlets-request-dispatcher-requestdispatcher-vs-sendredirect-what-is-a-request-dispatcher-and-how-does-it-work-what-is-a-request-dispatcher-and-how-do-i-use-it-inclu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Driver Registration In JDBC JDBC Connection Using the JDBC Driver Registering the JDBC driver Registering A JDBC driver JDBC Database Connections Basics Of JDBC  How To Establish A JDBC Connection</title>
		<link>http://www.mahol.org/blog/driver-registration-in-jdbc-jdbc-connecion-registering-the-jdbc-driver-registering-a-jdbc-driver-jdbc-database-connections-basics-of-jdbc-how-to-establish-a-jdbc-connection/</link>
		<comments>http://www.mahol.org/blog/driver-registration-in-jdbc-jdbc-connecion-registering-the-jdbc-driver-registering-a-jdbc-driver-jdbc-database-connections-basics-of-jdbc-how-to-establish-a-jdbc-connection/#comments</comments>
		<pubDate>Thu, 10 May 2012 17:46:34 +0000</pubDate>
		<dc:creator>asitkr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[OPPS]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Tech-Tips]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[basics of jdbc]]></category>
		<category><![CDATA[class.forName()]]></category>
		<category><![CDATA[database connecivity]]></category>
		<category><![CDATA[database connection]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[driver manager class]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[jdbc connection]]></category>

		<guid isPermaLink="false">http://www.mahol.org/blog/?p=852</guid>
		<description><![CDATA[Driver Registration In JDBC An interface links two unrelated objects.A driver in JDBC context is an interface which links java code to database for communication. Before ever the connection is established between the java programming end and the database end,the driver needs to be registered with the JVM by the means of DriverManager class.The DriverManager [...]


Related posts:<ol><li><a href='http://www.mahol.org/blog/transaction-locking-and-isolation-in-jdbc-transaction-isolation-levels-using-transactions-jdbc-isolation-example-jdbc-guide-basics-of-jdbc/' rel='bookmark' title='Permanent Link: Transaction Locking And Isolation In JDBC Transaction isolation levels Using Transactions JDBC Isolation Example JDBC Guide Basics Of JDBC'>Transaction Locking And Isolation In JDBC Transaction isolation levels Using Transactions JDBC Isolation Example JDBC Guide Basics Of JDBC</a></li>
<li><a href='http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/' rel='bookmark' title='Permanent Link: Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking'>Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking</a></li>
<li><a href='http://www.mahol.org/blog/apache-tomcat/' rel='bookmark' title='Permanent Link: Basics of tomcat Apache-Tomcat Tutorial Download and Run Tomcat'>Basics of tomcat Apache-Tomcat Tutorial Download and Run Tomcat</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Driver Registration In JDBC</strong></p>
<p>An interface links two unrelated objects.A driver in JDBC context is an interface which links java code to database for communication.</p>
<p>Before ever the connection is established between the java programming end and the database end,the driver needs to be registered with the JVM by the means of DriverManager class.The DriverManager class has a vector of drivers registered to it.Once the entry has been made in the vector of the DriverManager class the driver is said to be registered.Each driver has the implementation and is capable of registering itself with the DriverManager class.This implementation is written in the static initialization block of the driver class.</p>
<p>We know that the static initialization block for a class is executed every time we load the class in the class loader. So, in order to run the static initialization block in the class loader we need to run the following line of code so that the driver registers itself with the DriverManager class :</p>
<pre class="brush:java">Class.forName("DriverClass");</pre>
<p>We can load or compile a class in class loader by calling the Class.forName(&#8220;class name&#8221;) method of the reflection concept in java.</p>
<p>Now let us have a look at how  the static initialization block in the driver class looks like :</p>
<p>&nbsp;</p>
<pre class="brush:java">class Driver{

 static{
    --------
    DriverManager.registerDriver(Driver Class);
    ----
    ----
    ----
    }
}</pre>
<p>&nbsp;</p>
<p>The function registerDriver() of the DriverManager class takes driver class as one of the parameters and looks for an entry ofr that driver in the vector it has. If an entry is found it means that the driver is already registered and the reference is returned from the vector.UIf entry is not available in the vector,the entry is made and reference is returned.This way we say that the driver is registered and connection can be made with the database as follows :</p>
<pre class="brush:other">DriverManager.getConnection("Connection String","username","password");</pre>
<p>Here connection String is depenedent on what database we are using.A typical example is :</p>
<p>jdbc:postgresql://host:port/database</p>
<p>Here ,username and password are username and password for the database.</p>
Number of View :30

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mahol.org/blog/driver-registration-in-jdbc-jdbc-connecion-registering-the-jdbc-driver-registering-a-jdbc-driver-jdbc-database-connections-basics-of-jdbc-how-to-establish-a-jdbc-connection/&amp;title=Driver+Registration+In+JDBC+JDBC+Connection+Using+the+JDBC+Driver+Registering+the+JDBC+driver+Registering+A+JDBC+driver+JDBC+Database+Connections+Basics+Of+JDBC++How+To+Establish+A+JDBC+Connection" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Driver+Registration+In+JDBC+JDBC+Connection+Using+the+JDBC+Driver+Registering+th%5B..%5D+-+http://tinyurl.com/7y77n3m&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mahol.org/blog/driver-registration-in-jdbc-jdbc-connecion-registering-the-jdbc-driver-registering-a-jdbc-driver-jdbc-database-connections-basics-of-jdbc-how-to-establish-a-jdbc-connection/&amp;t=Driver+Registration+In+JDBC+JDBC+Connection+Using+the+JDBC+Driver+Registering+the+JDBC+driver+Registering+A+JDBC+driver+JDBC+Database+Connections+Basics+Of+JDBC++How+To+Establish+A+JDBC+Connection" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mahol.org/blog/driver-registration-in-jdbc-jdbc-connecion-registering-the-jdbc-driver-registering-a-jdbc-driver-jdbc-database-connections-basics-of-jdbc-how-to-establish-a-jdbc-connection/&amp;submitHeadline=Driver+Registration+In+JDBC+JDBC+Connection+Using+the+JDBC+Driver+Registering+the+JDBC+driver+Registering+A+JDBC+driver+JDBC+Database+Connections+Basics+Of+JDBC++How+To+Establish+A+JDBC+Connection&amp;submitSummary=Driver%20Registration%20In%20JDBC%0D%0A%0D%0AAn%20interface%20links%20two%20unrelated%20objects.A%20driver%20in%20JDBC%20context%20is%20an%20interface%20which%20links%20java%20code%20to%20database%20for%20communication.%0D%0A%0D%0ABefore%20ever%20the%20connection%20is%20established%20between%20the%20java%20programming%20end%20and%20the%20database%20end%2Cthe%20driver%20needs%20to%20be%20registered%20w&amp;submitCategory=world_news&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mahol.org/blog/driver-registration-in-jdbc-jdbc-connecion-registering-the-jdbc-driver-registering-a-jdbc-driver-jdbc-database-connections-basics-of-jdbc-how-to-establish-a-jdbc-connection/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.mahol.org/blog/driver-registration-in-jdbc-jdbc-connecion-registering-the-jdbc-driver-registering-a-jdbc-driver-jdbc-database-connections-basics-of-jdbc-how-to-establish-a-jdbc-connection/&amp;title=Driver+Registration+In+JDBC+JDBC+Connection+Using+the+JDBC+Driver+Registering+the+JDBC+driver+Registering+A+JDBC+driver+JDBC+Database+Connections+Basics+Of+JDBC++How+To+Establish+A+JDBC+Connection" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.mahol.org/blog/transaction-locking-and-isolation-in-jdbc-transaction-isolation-levels-using-transactions-jdbc-isolation-example-jdbc-guide-basics-of-jdbc/' rel='bookmark' title='Permanent Link: Transaction Locking And Isolation In JDBC Transaction isolation levels Using Transactions JDBC Isolation Example JDBC Guide Basics Of JDBC'>Transaction Locking And Isolation In JDBC Transaction isolation levels Using Transactions JDBC Isolation Example JDBC Guide Basics Of JDBC</a></li>
<li><a href='http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/' rel='bookmark' title='Permanent Link: Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking'>Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking</a></li>
<li><a href='http://www.mahol.org/blog/apache-tomcat/' rel='bookmark' title='Permanent Link: Basics of tomcat Apache-Tomcat Tutorial Download and Run Tomcat'>Basics of tomcat Apache-Tomcat Tutorial Download and Run Tomcat</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mahol.org/blog/driver-registration-in-jdbc-jdbc-connecion-registering-the-jdbc-driver-registering-a-jdbc-driver-jdbc-database-connections-basics-of-jdbc-how-to-establish-a-jdbc-connection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transaction Locking And Isolation In JDBC Transaction isolation levels Using Transactions JDBC Isolation Example JDBC Guide Basics Of JDBC</title>
		<link>http://www.mahol.org/blog/transaction-locking-and-isolation-in-jdbc-transaction-isolation-levels-using-transactions-jdbc-isolation-example-jdbc-guide-basics-of-jdbc/</link>
		<comments>http://www.mahol.org/blog/transaction-locking-and-isolation-in-jdbc-transaction-isolation-levels-using-transactions-jdbc-isolation-example-jdbc-guide-basics-of-jdbc/#comments</comments>
		<pubDate>Thu, 10 May 2012 06:49:01 +0000</pubDate>
		<dc:creator>asitkr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[OPPS]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Tech-Tips]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[database connection]]></category>
		<category><![CDATA[dirty read]]></category>
		<category><![CDATA[isolation level]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[non-repeatable read]]></category>
		<category><![CDATA[oops]]></category>
		<category><![CDATA[phantom read]]></category>
		<category><![CDATA[transcations]]></category>

		<guid isPermaLink="false">http://www.mahol.org/blog/?p=838</guid>
		<description><![CDATA[Transaction Locking And Isolation In JDBC Transaction is a set of instructions which follow atomicity,consistency,Integrity and durability. 1. Atomicity : This states that either all actions should complete or none should occur. 2. Consistency : This imposes certain business rule. 3. Integrity : This states that the two actions shall not interfere with each other [...]


Related posts:<ol><li><a href='http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/' rel='bookmark' title='Permanent Link: Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking'>Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking</a></li>
<li><a href='http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/' rel='bookmark' title='Permanent Link: How Container Does The Cookie Work in J2EE Define Cookie Cookies Explained Session In Servlet What Is Cookie How Apache Tomcat Handles Cookies Cookies Explained How Cookies Work Cookie Guide'>How Container Does The Cookie Work in J2EE Define Cookie Cookies Explained Session In Servlet What Is Cookie How Apache Tomcat Handles Cookies Cookies Explained How Cookies Work Cookie Guide</a></li>
<li><a href='http://www.mahol.org/blog/constructor-and-destructor-in-c-basics-of-opps-concepts-explained/' rel='bookmark' title='Permanent Link: Constructor And Destructor In C++ Basics Of OPPS Concepts Explained'>Constructor And Destructor In C++ Basics Of OPPS Concepts Explained</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Transaction Locking And Isolation In JDBC</strong></p>
<p>Transaction is a set of instructions which follow atomicity,consistency,Integrity and durability.</p>
<p>1. Atomicity : This states that either all actions should complete or none should occur.</p>
<p>2. Consistency : This imposes certain business rule.</p>
<p>3. Integrity : This states that the two actions shall not interfere with each other or access each others data.</p>
<p>4. Durability : This states that the changes occurred due to a certain action or transaction must be stored in a durable persistent storage.</p>
<p>&nbsp;</p>
<p>When we talk about the Transaction Locking And Isolation In JDBC, following are the issues we need to address when to concurrent transactions are taking place :</p>
<p>1. Dirty read : This happens when uncommitted data is read.Typical example is :</p>
<p>a. Transaction 1 inserts a row into a table.</p>
<p>b.Transaction 2 reads the new row.</p>
<p>c.Transaction 1 rolls back.</p>
<p>2. Non-repeatable read : This happens when data reads from the same table for the same row are not same.Typical example is</p>
<p>a. Transaction 1 reads a row.</p>
<p>b. Transaction 2 updates the row.</p>
<p>c. Transaction 1 reads the same row a second time and gets a different  results.</p>
<p>&nbsp;</p>
<p>3. Phantom Read : This occurs due to appearing of new records when same query is run at different times.Typical example is :</p>
<p>a. Transaction 1 reads all rows that satisfy a WHERE clause.</p>
<p>b. Transaction 2 inserts additional rows that satisfies the WHERE clause.</p>
<p>c. Transaction 1 executes  the WHERE condition and picks up the additional row.</p>
<p>There are different transaction isolation levels used from JDBC coding to address these issues.The function to set isolation level is :</p>
<p>&nbsp;</p>
<pre class="brush:java">con.setTranscationIsolationLevel(intvalue);</pre>
<pre class="brush:java"></pre>
<p>Different integer values can be provided as follows :</p>
<p>0 &#8211; JDBC_TRANSACTION_NONE<br />
1 &#8211; JDBC_TRANSACTION_READ_UNCOMMITTED<br />
2 &#8211; JDBC_TRANSACTION_READ_COMMITTED<br />
4 &#8211; JDBC_TRANSACTION_REPEATABLE_READ<br />
8 &#8211; JDBC_TRANSACTION_SERIALIZABLE</p>
<p>Once we set the isolation levels using the above function,we can address the issues of transaction level in JDBC connection.As the isolation     level increases it gets stricter and lower level problems are also addressed.If we have set the value to 8 ,the isolation level with value lesser than 8 ,ie. 0,1,2,4, are also taken  care of.</p>
Number of View :39

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mahol.org/blog/transaction-locking-and-isolation-in-jdbc-transaction-isolation-levels-using-transactions-jdbc-isolation-example-jdbc-guide-basics-of-jdbc/&amp;title=Transaction+Locking+And+Isolation+In+JDBC+Transaction+isolation+levels+Using+Transactions+JDBC+Isolation+Example+JDBC+Guide+Basics+Of+JDBC" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Transaction+Locking+And+Isolation+In+JDBC+Transaction+isolation+levels+Using+Tra%5B..%5D+-+http://tinyurl.com/7grzjtz&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mahol.org/blog/transaction-locking-and-isolation-in-jdbc-transaction-isolation-levels-using-transactions-jdbc-isolation-example-jdbc-guide-basics-of-jdbc/&amp;t=Transaction+Locking+And+Isolation+In+JDBC+Transaction+isolation+levels+Using+Transactions+JDBC+Isolation+Example+JDBC+Guide+Basics+Of+JDBC" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mahol.org/blog/transaction-locking-and-isolation-in-jdbc-transaction-isolation-levels-using-transactions-jdbc-isolation-example-jdbc-guide-basics-of-jdbc/&amp;submitHeadline=Transaction+Locking+And+Isolation+In+JDBC+Transaction+isolation+levels+Using+Transactions+JDBC+Isolation+Example+JDBC+Guide+Basics+Of+JDBC&amp;submitSummary=Transaction%20Locking%20And%20Isolation%20In%20JDBC%0D%0A%0D%0ATransaction%20is%20a%20set%20of%20instructions%20which%20follow%20atomicity%2Cconsistency%2CIntegrity%20and%20durability.%0D%0A%0D%0A1.%20Atomicity%20%3A%20This%20states%20that%20either%20all%20actions%20should%20complete%20or%20none%20should%20occur.%0D%0A%0D%0A2.%20Consistency%20%3A%20This%20imposes%20certain%20business%20rule.%0D%0A%0D%0A3.%20Int&amp;submitCategory=world_news&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mahol.org/blog/transaction-locking-and-isolation-in-jdbc-transaction-isolation-levels-using-transactions-jdbc-isolation-example-jdbc-guide-basics-of-jdbc/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.mahol.org/blog/transaction-locking-and-isolation-in-jdbc-transaction-isolation-levels-using-transactions-jdbc-isolation-example-jdbc-guide-basics-of-jdbc/&amp;title=Transaction+Locking+And+Isolation+In+JDBC+Transaction+isolation+levels+Using+Transactions+JDBC+Isolation+Example+JDBC+Guide+Basics+Of+JDBC" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/' rel='bookmark' title='Permanent Link: Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking'>Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking</a></li>
<li><a href='http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/' rel='bookmark' title='Permanent Link: How Container Does The Cookie Work in J2EE Define Cookie Cookies Explained Session In Servlet What Is Cookie How Apache Tomcat Handles Cookies Cookies Explained How Cookies Work Cookie Guide'>How Container Does The Cookie Work in J2EE Define Cookie Cookies Explained Session In Servlet What Is Cookie How Apache Tomcat Handles Cookies Cookies Explained How Cookies Work Cookie Guide</a></li>
<li><a href='http://www.mahol.org/blog/constructor-and-destructor-in-c-basics-of-opps-concepts-explained/' rel='bookmark' title='Permanent Link: Constructor And Destructor In C++ Basics Of OPPS Concepts Explained'>Constructor And Destructor In C++ Basics Of OPPS Concepts Explained</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mahol.org/blog/transaction-locking-and-isolation-in-jdbc-transaction-isolation-levels-using-transactions-jdbc-isolation-example-jdbc-guide-basics-of-jdbc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How Container Does The Cookie Work in J2EE Define Cookie Cookies Explained Session In Servlet What Is Cookie How Apache Tomcat Handles Cookies Cookies Explained How Cookies Work Cookie Guide</title>
		<link>http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/</link>
		<comments>http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/#comments</comments>
		<pubDate>Wed, 09 May 2012 09:59:22 +0000</pubDate>
		<dc:creator>asitkr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[OPPS]]></category>
		<category><![CDATA[Tech-Tips]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[apache tomcat server]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[Session tracking]]></category>

		<guid isPermaLink="false">http://www.mahol.org/blog/?p=829</guid>
		<description><![CDATA[How container does the cookie work? &#160; A Cookie is a key value pair primarily used by the container to pass the session id in order to maintain session between client and server. There can be user defined cookies as well to use cookie as attributes to pass values from one part of the web [...]


Related posts:<ol><li><a href='http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/' rel='bookmark' title='Permanent Link: Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking'>Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking</a></li>
<li><a href='http://www.mahol.org/blog/apache-tomcat/' rel='bookmark' title='Permanent Link: Basics of tomcat Apache-Tomcat Tutorial Download and Run Tomcat'>Basics of tomcat Apache-Tomcat Tutorial Download and Run Tomcat</a></li>
<li><a href='http://www.mahol.org/blog/a-hello-world-servlet-servlet-tutorial-servlet-examples/' rel='bookmark' title='Permanent Link: A Hello,World Servlet Servlet Tutorial Servlet Examples Run servlet on tomcat'>A Hello,World Servlet Servlet Tutorial Servlet Examples Run servlet on tomcat</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>How container does the cookie work?</strong></p>
<p>&nbsp;</p>
<p>A Cookie is a key value pair primarily used by the container to pass the session id in order to maintain session between client and server. There can be user defined cookies as well to use cookie as attributes to pass values from one part of the web application to another.</p>
<p>The user only requests for the session,creating a session object,attaching the session id with the session object and sending it to the client side or the browser with the response is done by the server at the back end. These things the code has nothing to bother about,the code asks for the session and these things happen automatically.</p>
<p>&nbsp;</p>
<p>The code below shows how to get a session object in servlet :</p>
<pre class="brush:java">HttpSession sess = request.getSession();</pre>
<p>&nbsp;</p>
<p>With the help of the above written code,the session can be retrieved from the server.Following are the steps covered by the server as soon as this line of code executes :</p>
<p>1. HttpSession object is created</p>
<p>2. Unique Session id is created</p>
<p>3. A new cookie object is created.</p>
<p>4. Session id is associated with cookie</p>
<p>5. Cookie is set Into the response to be sent to client side</p>
<p>&nbsp;</p>
<p>These are the steps involved in sending the cookie with the response if session does not exist .</p>
<p>The same code when executed does the work of retrieving a session object from request if it exists.If session already exists,the server finds the session id from the request(since cookie will be sent to the server from client side as part of the url).The server finds out the unique session id from the cookie and retrieves the session object with the matching Session id.</p>
<p>Thus all the cookie work happens behind the scene.</p>
<p>To know whether the session already existed or was just created,we can ask the session object itself as :</p>
<pre class="brush:java">sess.isNew();</pre>
<p>If it returns true ,it means session is created otherwise it is a preexisting session.</p>
Number of View :33

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/&amp;title=How+Container+Does+The+Cookie+Work+in+J2EE+Define+Cookie+Cookies+Explained+Session+In+Servlet+What+Is+Cookie+How+Apache+Tomcat+Handles+Cookies+Cookies+Explained+How+Cookies+Work+Cookie+Guide" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=How+Container+Does+The+Cookie+Work+in+J2EE+Define+Cookie+Cookies+Explained+Sessi%5B..%5D+-+http://tinyurl.com/bmx35o5&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/&amp;t=How+Container+Does+The+Cookie+Work+in+J2EE+Define+Cookie+Cookies+Explained+Session+In+Servlet+What+Is+Cookie+How+Apache+Tomcat+Handles+Cookies+Cookies+Explained+How+Cookies+Work+Cookie+Guide" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/&amp;submitHeadline=How+Container+Does+The+Cookie+Work+in+J2EE+Define+Cookie+Cookies+Explained+Session+In+Servlet+What+Is+Cookie+How+Apache+Tomcat+Handles+Cookies+Cookies+Explained+How+Cookies+Work+Cookie+Guide&amp;submitSummary=How%20container%20does%20the%20cookie%20work%3F%0D%0A%0D%0A%26nbsp%3B%0D%0A%0D%0AA%20Cookie%20is%20a%20key%20value%20pair%20primarily%20used%20by%20the%20container%20to%20pass%20the%20session%20id%20in%20order%20to%20maintain%20session%20between%20client%20and%20server.%20There%20can%20be%20user%20defined%20cookies%20as%20well%20to%20use%20cookie%20as%20attributes%20to%20pass%20values%20from%20one%20part%20of%20the%20web%20a&amp;submitCategory=world_news&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/&amp;title=How+Container+Does+The+Cookie+Work+in+J2EE+Define+Cookie+Cookies+Explained+Session+In+Servlet+What+Is+Cookie+How+Apache+Tomcat+Handles+Cookies+Cookies+Explained+How+Cookies+Work+Cookie+Guide" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/' rel='bookmark' title='Permanent Link: Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking'>Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking</a></li>
<li><a href='http://www.mahol.org/blog/apache-tomcat/' rel='bookmark' title='Permanent Link: Basics of tomcat Apache-Tomcat Tutorial Download and Run Tomcat'>Basics of tomcat Apache-Tomcat Tutorial Download and Run Tomcat</a></li>
<li><a href='http://www.mahol.org/blog/a-hello-world-servlet-servlet-tutorial-servlet-examples/' rel='bookmark' title='Permanent Link: A Hello,World Servlet Servlet Tutorial Servlet Examples Run servlet on tomcat'>A Hello,World Servlet Servlet Tutorial Servlet Examples Run servlet on tomcat</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mahol.org/blog/how-container-does-the-cookie-work-in-j2ee-define-cookie-cookies-explained-session-in-servlet-what-is-cookie-how-apache-tomcat-handles-cookies-cookies-explained-how-cookies-work-cookie-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Concept Of Session In J2EE Session Tracking In J2EE Session Management Seesion Concept Servlet Basics Servlet Guide Session Tracking</title>
		<link>http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/</link>
		<comments>http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/#comments</comments>
		<pubDate>Tue, 08 May 2012 11:01:57 +0000</pubDate>
		<dc:creator>asitkr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Tech-Tips]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[getSesson()]]></category>
		<category><![CDATA[hidden fields]]></category>
		<category><![CDATA[http stateless protocol]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[session amangement]]></category>
		<category><![CDATA[sessions]]></category>
		<category><![CDATA[url rewriting]]></category>

		<guid isPermaLink="false">http://www.mahol.org/blog/?p=821</guid>
		<description><![CDATA[Sessions In J2EE(How to maintain session in java web applications) Session in J2EE application is the time of interaction between the client and the server.A session in used to retain the state of a client.As we know that http is connectionless protocol,after each request and response cycle between the client and the server,the connection is [...]


Related posts:<ol><li><a href='http://www.mahol.org/blog/how-to-redirect-from-one-servlet-to-another-servlet-basics-servlet-redirect/' rel='bookmark' title='Permanent Link: How To Redirect From One Servlet To Another Servlet Basics Servlet Redirect'>How To Redirect From One Servlet To Another Servlet Basics Servlet Redirect</a></li>
<li><a href='http://www.mahol.org/blog/a-hello-world-servlet-servlet-tutorial-servlet-examples/' rel='bookmark' title='Permanent Link: A Hello,World Servlet Servlet Tutorial Servlet Examples Run servlet on tomcat'>A Hello,World Servlet Servlet Tutorial Servlet Examples Run servlet on tomcat</a></li>
<li><a href='http://www.mahol.org/blog/how-to-forward-from-one-servlet-to-another-servlet-essentials-servlet-forward/' rel='bookmark' title='Permanent Link: how to forward from one servlet to another  Servlet Essentials Servlet Forward'>how to forward from one servlet to another  Servlet Essentials Servlet Forward</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Sessions In J2EE(How to maintain session in java web applications)</strong></p>
<p>Session in J2EE application is the time of interaction between the client and the server.A session in used to retain the state of a client.As we know that http is connectionless protocol,after each request and response cycle between the client and the server,the connection is broken. It seems logical to break the connection as bandwidth is an expensive resource and needs to be relinquished so that the same can be used for another request.This is the reason http is the protocol used to access the web application in any web technology.</p>
<p>With the advantage of releasing the bandwidth comes the issue of maintaining the session in J2EE ,as after the request response cycle,the server does not remember the client.</p>
<p>So some extra work is needed in order to maintain the session.</p>
<p>The code to get a session object in servlet is as follows :</p>
<pre class="brush:java">request.getSession(TRUE);</pre>
<p>or</p>
<pre class="brush:java">request.getSession(FALSE);</pre>
<p>&nbsp;</p>
<p>The difference between the two overloaded functions is that the function with &#8216; TRUE&#8217; as parameter returns a new session object even if a session does not  exist otherwise it will return the preexisting session object but in the later case the function will return the existing session object if it exists or if not existing a null  will be returned.</p>
<p>As we have got the session in a servlet now,it will be lost after a request response cycle.So,in order to maintain session we need to follow either of the approaches from:</p>
<p>1. Hidden parameters</p>
<p>2. Cookies</p>
<p>3. URL rewriting</p>
<p>1. Hidden parameter : In this case we pass the session id allotted by the server to the session object via parameters</p>
<p>2. Cookies : In this case the browser downloads the cookies at the client side,so that it can append the session id with each request.Creating a cookie ,attaching session id to it and sending it to the client side is all done implicitly by the server as soon as we execute the code</p>
<pre class="brush:java">request.getSession(TRUE/FALSE);</pre>
<p>&nbsp;</p>
<p>3. URL rewriting is something to fall upon if the browser at the client side doe snot accept cookies.In such cases we encode the URL with an extra info called sessionid as the parameter.</p>
<p>The code for url rewriting is as follows :</p>
<pre class="brush:java">response.encodeRedirectUrl("url-pattern");</pre>
<p>&nbsp;</p>
Number of View :37

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/&amp;title=Concept+Of+Session+In+J2EE+Session+Tracking+In+J2EE+Session+Management+Seesion+Concept+Servlet+Basics+Servlet+Guide+Session+Tracking" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Concept+Of+Session+In+J2EE+Session+Tracking+In+J2EE+Session+Management+Seesion+C%5B..%5D+-+http://tinyurl.com/6s7o78m&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/&amp;t=Concept+Of+Session+In+J2EE+Session+Tracking+In+J2EE+Session+Management+Seesion+Concept+Servlet+Basics+Servlet+Guide+Session+Tracking" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/&amp;submitHeadline=Concept+Of+Session+In+J2EE+Session+Tracking+In+J2EE+Session+Management+Seesion+Concept+Servlet+Basics+Servlet+Guide+Session+Tracking&amp;submitSummary=Sessions%20In%20J2EE%28How%20to%20maintain%20session%20in%20java%20web%20applications%29%0D%0A%0D%0ASession%20in%20J2EE%20application%20is%20the%20time%20of%20interaction%20between%20the%20client%20and%20the%20server.A%20session%20in%20used%20to%20retain%20the%20state%20of%20a%20client.As%20we%20know%20that%20http%20is%20connectionless%20protocol%2Cafter%20each%20request%20and%20response%20cycle%20betwe&amp;submitCategory=world_news&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/&amp;title=Concept+Of+Session+In+J2EE+Session+Tracking+In+J2EE+Session+Management+Seesion+Concept+Servlet+Basics+Servlet+Guide+Session+Tracking" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>



<p>Related posts:<ol><li><a href='http://www.mahol.org/blog/how-to-redirect-from-one-servlet-to-another-servlet-basics-servlet-redirect/' rel='bookmark' title='Permanent Link: How To Redirect From One Servlet To Another Servlet Basics Servlet Redirect'>How To Redirect From One Servlet To Another Servlet Basics Servlet Redirect</a></li>
<li><a href='http://www.mahol.org/blog/a-hello-world-servlet-servlet-tutorial-servlet-examples/' rel='bookmark' title='Permanent Link: A Hello,World Servlet Servlet Tutorial Servlet Examples Run servlet on tomcat'>A Hello,World Servlet Servlet Tutorial Servlet Examples Run servlet on tomcat</a></li>
<li><a href='http://www.mahol.org/blog/how-to-forward-from-one-servlet-to-another-servlet-essentials-servlet-forward/' rel='bookmark' title='Permanent Link: how to forward from one servlet to another  Servlet Essentials Servlet Forward'>how to forward from one servlet to another  Servlet Essentials Servlet Forward</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mahol.org/blog/concept-of-session-in-j2ee-session-tracking-in-j2ee-session-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	<item><title>Open MP in short [del.icio.us]</title><link>http://vergil.chemistry.gatech.edu/resources/programming/OpenMP.pdf</link><category>linux</category><category>programming</category><dc:creator>bhagwat</dc:creator><pubDate>Tue, 08 Nov 2011 21:57:55 PST</pubDate><guid isPermaLink="false">http://www.delicious.com/url/bbaa8daba064c01ba113a7bb360ec861#bhagwat</guid><description>OpenMP: An API for, Portable Shared, Memory Programming</description><wfw:commentRss>http://feeds.delicious.com/v2/rss/url/bbaa8daba064c01ba113a7bb360ec861</wfw:commentRss></item><item><title>Hunting the core | FromDual [del.icio.us]</title><link>http://fromdual.com/hunting-the-core</link><category>linux</category><dc:creator>bhagwat</dc:creator><pubDate>Thu, 03 Nov 2011 00:25:54 PDT</pubDate><guid isPermaLink="false">http://www.delicious.com/url/72a36810170d7a73938ab54e9e8a9f96#bhagwat</guid><description>All about Core files under Linux, how to create core files, how to debug using core files.</description><wfw:commentRss>http://feeds.delicious.com/v2/rss/url/72a36810170d7a73938ab54e9e8a9f96</wfw:commentRss></item><item><title>What really happened on Mars? -- Authoritative Account [del.icio.us]</title><link>http://research.microsoft.com/en-us/um/people/mbj/Mars_Pathfinder/Authoritative_Account.html</link><category>space</category><category>embedded</category><category>accident</category><category>microsoft</category><dc:creator>bhagwat</dc:creator><pubDate>Thu, 03 Nov 2011 00:14:09 PDT</pubDate><guid isPermaLink="false">http://www.delicious.com/url/e2661f9a34b40ec5f3f02cdb6526259c#bhagwat</guid><description>What really happened on Mars ? 
How did they fix the problem in mars pathfinder, interesting about Vxworks.</description><wfw:commentRss>http://feeds.delicious.com/v2/rss/url/e2661f9a34b40ec5f3f02cdb6526259c</wfw:commentRss></item><item><title>XMind - Social Brainstorming and Mind Mapping [del.icio.us]</title><link>http://www.xmind.net/share/</link><category>mindmaps</category><category>diagrams</category><category>knowledge</category><category>management</category><dc:creator>bhagwat</dc:creator><pubDate>Mon, 26 Sep 2011 01:54:11 PDT</pubDate><guid isPermaLink="false">http://www.delicious.com/url/59cf035351a7c5fa1cf935ef7bc89daf#bhagwat</guid><description>XMind is an open source brainstorming and mind mapping software tool,  capturing ideas, organizing various charts, and share them with collaboration. It supports mind maps, Ishikawa diagrams,  tree diagrams, organization charts, and spreadsheets.</description><wfw:commentRss>http://feeds.delicious.com/v2/rss/url/59cf035351a7c5fa1cf935ef7bc89daf</wfw:commentRss></item><item><title>Linux 101 Hacks — Free eBook [del.icio.us]</title><link>http://linux.101hacks.com/</link><category>linux</category><category>books</category><category>free</category><dc:creator>bhagwat</dc:creator><pubDate>Tue, 13 Sep 2011 02:47:34 PDT</pubDate><guid isPermaLink="false">http://www.delicious.com/url/8f9e64f2bf73b6c98d5b0f78da66b6a5#bhagwat</guid><description>Free ebook on linux system administrator.</description><wfw:commentRss>http://feeds.delicious.com/v2/rss/url/8f9e64f2bf73b6c98d5b0f78da66b6a5</wfw:commentRss></item><item><title>Dave Marshall's Links [del.icio.us]</title><link>http://www.cs.cf.ac.uk/Dave/</link><category>programming</category><category>c</category><category>reference</category><category>tutorial</category><dc:creator>bhagwat</dc:creator><pubDate>Tue, 13 Sep 2011 02:47:04 PDT</pubDate><guid isPermaLink="false">http://www.delicious.com/url/76f5ba8c6919dec862ae8bc581093af9#bhagwat</guid><description>Tutorial for C/Linux programming from basic to advanced, Perl , AI and internet programming. Good reference for begineers.</description><wfw:commentRss>http://feeds.delicious.com/v2/rss/url/76f5ba8c6919dec862ae8bc581093af9</wfw:commentRss></item><item><title>Bruce Perens | Linux Journal [del.icio.us]</title><link>http://www.linuxjournal.com/user/800757</link><category>embedded</category><category>linux</category><dc:creator>bhagwat</dc:creator><pubDate>Tue, 16 Aug 2011 23:52:46 PDT</pubDate><guid isPermaLink="false">http://www.delicious.com/url/667a91c68e8893ae334e397156fcf764#bhagwat</guid><description>Build your Embedded Linux Systems with Busybox, Building the Kernel, creating filesystem, Step by Step guide.</description><wfw:commentRss>http://feeds.delicious.com/v2/rss/url/667a91c68e8893ae334e397156fcf764</wfw:commentRss></item><item><title>LIBC guide and C programming in Linux [del.icio.us]</title><link>http://www.cs.bham.ac.uk/~exr/teaching/lectures/systems/07_08/docs/libc/libc_toc.html</link><category>linux</category><dc:creator>bhagwat</dc:creator><pubDate>Fri, 29 Jul 2011 02:07:01 PDT</pubDate><guid isPermaLink="false">http://www.delicious.com/url/6a40ab28b86624cc3b0d3b8b3fc0b544#bhagwat</guid><description>C programming language and basic programming concepts, •C Language Facilities in the Library,•Virtual Memory Allocation And Paging, •String and Array Utilities, •File System Interface, •Pipes and FIFOs, •Sockets •Low-Level Arithmetic Functions, •Searching and Sorting, •Pattern Matching •Date and Time,</description><wfw:commentRss>http://feeds.delicious.com/v2/rss/url/6a40ab28b86624cc3b0d3b8b3fc0b544</wfw:commentRss></item><item><title>CE 155 - Operating Systems - Sections A and B [del.icio.us]</title><link>http://www.amparo.net/ce155/</link><category>linux</category><dc:creator>bhagwat</dc:creator><pubDate>Fri, 29 Jul 2011 02:04:21 PDT</pubDate><guid isPermaLink="false">http://www.delicious.com/url/939325c38cb53c333a24f0e57b14d232#bhagwat</guid><description>Simple C code examples on , processes and threads, deadlocks, memory management, and file systems.</description><wfw:commentRss>http://feeds.delicious.com/v2/rss/url/939325c38cb53c333a24f0e57b14d232</wfw:commentRss></item><item><title>SWEBOK Guide - Software Engineering Profession [del.icio.us]</title><link>http://www.computer.org/portal/web/swebok/html/contents</link><category>software</category><category>engineering</category><category>book</category><category>softwareengineering</category><category>knowledge</category><category>books</category><dc:creator>bhagwat</dc:creator><pubDate>Tue, 31 May 2011 04:53:42 PDT</pubDate><guid isPermaLink="false">http://www.delicious.com/url/74fe0519a6e450d6f014a8bf7f781777#bhagwat</guid><description>The IEEE Computer Society has put together a Guide for the Software Engineering Body of Knowledge. The Guide should not be confused with the Body of Knowledge itself, which already exists in the published literature. The purpose of the Guide is to describe what portion of the Body of Knowledge is generally accepted, to organize that portion, and to provide a topical access to it.</description><wfw:commentRss>http://feeds.delicious.com/v2/rss/url/74fe0519a6e450d6f014a8bf7f781777</wfw:commentRss></item></channel>
</rss><!-- Dynamic page generated in 3.697 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-05-17 10:20:26 -->

