Why the container loads server at the application startup and how?

devquora
devquora

Posted On: Feb 22, 2018

 

In general, on the very first request of the client, the server container loads a servlet. But in case, the servlet is too heavy that it takes much time to load, at that time we might want it to load during the application startup. To do this, the user can use WebServlet notation or loadOnStartup variable to stimuli container. Or, we can use a load-on-startup element with a servlet configuration in web.xml file to load the servlet on startup.

Syntax:

<servlet>
<servlet-name>coo </servlet-name>
<servlet-class>com.coo.servlets.Coo </servlet-class>
<load-on-startup>6 </load-on-startup>
</servlet> 

If you want that the container loads the servlet on client request, then the load-on-startup value should be negative otherwise if it’s positive then the loading will start on application startup.

If there are many servlets with different load-on-startup values, then that servlet will be loaded first which have the lowest value.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Servlet interview questions

    What do you mean by Servlet?

    It is designed by the Java software company. It is used to extend the ability of the server...

    Servlet interview questions

    Differentiate between the web server and application server?

    Web Server is the connection between the HTTP and HTML...

    Servlet interview questions

    Which HTTP method is said to be non-idempotent and idempotent?

    If any HTTP brings the same result every time then it means it is idempotent...