<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java Interview Questions &#187; servlet life cycle</title>
	<atom:link href="http://www.bestjavainterviewquestions.com/category/java-important-notes/servlet-life-cycle/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bestjavainterviewquestions.com</link>
	<description>Java Interview Questions &#124; Core Java Interview Questions &#124; Advanced Java Interview Questions &#124; EJB Interview Questions &#124; J2EE Interview Questions &#124; Hibernate Interview Questions</description>
	<lastBuildDate>Fri, 03 Feb 2012 10:23:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Life Cycle of Servlets</title>
		<link>http://www.bestjavainterviewquestions.com/life-cycle-of-servlets/</link>
		<comments>http://www.bestjavainterviewquestions.com/life-cycle-of-servlets/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 17:19:30 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[servlet life cycle]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=92</guid>
		<description><![CDATA[The life cycle of a servlet can be categorized into four parts: 1. Loading and Inatantiation: The servlet container loads the servlet during startup or when the first request is made. The loading of the servlet depends on the attribute of web.xml file. If the attribute has a positive value then the servlet is load [...]]]></description>
			<content:encoded><![CDATA[<p><strong>The life cycle of a servlet can be categorized into four parts:</strong><br />
1.	Loading and Inatantiation: The servlet container loads the servlet during startup or when the first request is made. The loading of the servlet depends on the attribute  of web.xml file. If the attribute  has a positive value then the servlet is load with loading of the container otherwise it load when the first request comes for service. After loading of the servlet, the container creates the instances of the servlet.<br />
2.	Initialization: After creating the instances, the servlet container calls the init() method and passes the servlet initialization parameters to the init() method. The init() must be called by the servlet container before the servlet can service any request. The initialization parameters persist untill the servlet is destroyed. The init() method is called only once throughout the life cycle of the servlet.</p>
<p>The servlet will be available for service if it is loaded successfully otherwise the servlet container unloads the servlet.<br />
3.	Servicing the Request: After successfully completing the initialization process, the servlet will be available for service. Servlet creates seperate threads for each request. The sevlet container calls the service() method for servicing any request. The service() method determines the kind of request and calls the appropriate method (doGet() or doPost()) for handling the request and sends response to the client using the methods of the response object.<br />
4.	Destroying the Servlet: If the servlet is no longer needed for servicing any request, the servlet container calls the destroy() method . Like the init() method this method is also called only once throughout the life cycle of the servlet. Calling the destroy() method indicates to the servlet container not to sent the any request for service and the servlet  releases all the resources associated with it. Java Virtual Machine claims for the memory associated with the resources for garbage collection.</p>
<p><a href="http://www.bestjavainterviewquestions.com/wp-content/uploads/2008/08/servletlifecycle.jpg"><img class="alignnone size-medium wp-image-154" title="servletlifecycle" src="http://www.bestjavainterviewquestions.com/wp-content/uploads/2008/08/servletlifecycle-300x196.jpg" alt="" width="385" height="205" /></a></p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>August 9, 2008 -- <a href="http://www.bestjavainterviewquestions.com/some-important-methos-in-applets/" title="Some important methos in Applets">Some important methos in Applets</a> (0)</li><li>September 22, 2008 -- <a href="http://www.bestjavainterviewquestions.com/what-are-command-line-arguments-in-java/" title="What are Command Line Arguments in Java">What are Command Line Arguments in Java</a> (0)</li><li>September 22, 2008 -- <a href="http://www.bestjavainterviewquestions.com/what-is-jre-explain/" title="What is JRE ? Explain">What is JRE ? Explain</a> (1)</li><li>September 2, 2008 -- <a href="http://www.bestjavainterviewquestions.com/define-session-id/" title="Define Session ID">Define Session ID</a> (0)</li><li>September 22, 2008 -- <a href="http://www.bestjavainterviewquestions.com/creating-the-java-class/" title="Creating the Java Class">Creating the Java Class</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/life-cycle-of-servlets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

