What is preinitialization of servlet

In the java servlet life cycle, the first phase is called “Creation and intialization“.

The java servlet container first creates the servlet instance and then executes the init() method. This initialization can be done in Two ways. The default way is that, the java servlet is initialized when the servlet is called for the first time. This type of servlet initialization is called lazy loading.

The other way is through the <load-on-startup>non-zero-integer</load-on-startup> tag using the deployment descriptor web.xml. 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 preloading or preinitialization of a servlet.
Servlet 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.

<pre><servlet>
       <servlet-name>Servlet-URL</servlet-name>
       <servlet-class>com.shivasoft.LoginServlet</servlet-class>
       <load-on-startup>2</load-on-startup>
</servlet></pre>
Advertisements

About Sanju
I am Software Programmer. I am working in JAVA/J2EE Technologies.

3 Responses to What is preinitialization of servlet

  1. Fantastic items from you, man. I have take into accout your stuff previous to and you’re just extremely excellent. I actually like what you’ve got here, really like what you’re saying and the best way by which you say it. You make it entertaining and you continue to take care of to stay it wise. I can not wait to read far more from you. This is actually a wonderful site.

  2. mercadee says:

    Servlets are loaded from the classpath like all Java classes. Normally, users put servlets in WEB-INF/classes so Resin will automatically reload them when they change.

  3. jelly defense apk download says:

    What is preinitialization of servlet Java Magic I was recommended this website by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my problem. You are incredible! Thanks! your article about What is preinitialization of servlet Java MagicBest Regards Shane

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: