{"id":1464,"date":"2011-02-08T23:03:26","date_gmt":"2011-02-08T17:33:26","guid":{"rendered":"http:\/\/JitendraZaa.com\/blog\/?p=1464"},"modified":"2011-02-08T23:03:26","modified_gmt":"2011-02-08T17:33:26","slug":"what-is-preinitialization-of-servlet","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/java\/servlet\/what-is-preinitialization-of-servlet\/","title":{"rendered":"What is preinitialization of servlet"},"content":{"rendered":"<p>In the java servlet life cycle, the first phase is called &#8220;<strong>Creation and intialization<\/strong>&#8220;.<\/p>\n<p>The java servlet container first creates the servlet instance and then executes the <strong>init()<\/strong> method. This initialization can be done in <strong>Two ways<\/strong>. The default way is that, the java servlet is initialized <strong>when the servlet is called for the first time<\/strong>. This type of servlet initialization is called <strong>lazy loading<\/strong>.<\/p>\n<p><!--more-->The other way is through the<strong> &lt;load-on-startup&gt;non-zero-integer&lt;\/load-on-startup&gt; <\/strong> tag using the deployment descriptor <strong>web.xml<\/strong>. This makes the java servlet to be loaded and initialized when the server starts. This process of loading a java servlet before receiving any request is called <strong>preloading or preinitialization of a servlet<\/strong>.<br \/>\nServlet are loaded in the order of number(non-zero-integer) specified. That is, lower(example: 1) the load-on-startup value is loaded first and then servlet with higher values are loaded.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;servlet&gt;\n       &lt;servlet-name&gt;Servlet-URL&lt;\/servlet-name&gt;\n       &lt;servlet-class&gt;com.shivasoft.LoginServlet&lt;\/servlet-class&gt;\n       &lt;load-on-startup&gt;2&lt;\/load-on-startup&gt;\n&lt;\/servlet&gt;\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>What is preinitialization of servlet <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11],"tags":[125],"class_list":["post-1464","post","type-post","status-publish","format-standard","hentry","category-servlet","tag-j2ee"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1477,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/servlet\/why-not-to-write-constructor-in-servlet\/","url_meta":{"origin":1464,"position":0},"title":"Why not to write constructor in Servlet","author":"Jitendra","date":"February 11, 2011","format":false,"excerpt":"Why not to write constructor in Servlet","rel":"","context":"In &quot;Servlet&quot;","block_context":{"text":"Servlet","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/servlet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1479,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/servlet\/example-to-override-the-init-method-of-the-servlet\/","url_meta":{"origin":1464,"position":1},"title":"Example to Override the init() method of the servlet","author":"Jitendra","date":"February 11, 2011","format":false,"excerpt":"Example to Override the init() method of the servlet","rel":"","context":"In &quot;Servlet&quot;","block_context":{"text":"Servlet","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/servlet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1467,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/servlet\/difference-between-servletcontext-and-servletconfig\/","url_meta":{"origin":1464,"position":2},"title":"Difference between servletContext and ServletConfig","author":"Jitendra","date":"February 8, 2011","format":false,"excerpt":"What is difference between servletContext and ServletConfig?","rel":"","context":"In &quot;Servlet&quot;","block_context":{"text":"Servlet","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/servlet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1494,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/servlet\/life-cycle-of-servlet\/","url_meta":{"origin":1464,"position":3},"title":"Life Cycle of Servlet","author":"Jitendra","date":"February 12, 2011","format":false,"excerpt":"Explain Life Cycle of Servlet","rel":"","context":"In &quot;Servlet&quot;","block_context":{"text":"Servlet","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/servlet\/"},"img":{"alt_text":"Servlet Life Cycle","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/02\/Servlet-Life-Cycle.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1501,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/servlet\/difference-in-sendredirect-and-requestdispatcher-in-servlet\/","url_meta":{"origin":1464,"position":4},"title":"Difference in SendRedirect() and RequestDispatcher() in Servlet","author":"Jitendra","date":"February 13, 2011","format":false,"excerpt":"difference in SendRedirect() and RequestDispatcher() in Servlet","rel":"","context":"In &quot;Servlet&quot;","block_context":{"text":"Servlet","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/servlet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1482,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/servlet\/how-container-handles-the-servlet-request\/","url_meta":{"origin":1464,"position":5},"title":"How container handles the Servlet request","author":"Jitendra","date":"February 12, 2011","format":false,"excerpt":"How container handles the Servlet request or How the apache Tomcat works","rel":"","context":"In &quot;Servlet&quot;","block_context":{"text":"Servlet","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/servlet\/"},"img":{"alt_text":"Client Browse Servlet URL","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/02\/Client-Browse-Servlet-URL.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/1464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=1464"}],"version-history":[{"count":0,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/1464\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=1464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=1464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=1464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}