Specifying when servlets are loaded and initialized

By default, Liberty defers servlet loading until a request is received for the associated web application. You can override this default behavior by specifying the web container deferServletLoad attribute to false.

About this task

The servlet specification defines the load-on-startup servlet attribute, which is specified in the web.xml file of a web application. If a servlet has a non-negative value for the load-on-startup attribute, the servlet must be loaded and initialized when the web application is deployed. Liberty optimizes server start time and memory use by not starting a servlet until a request is received for the web application. You can override this deferral so that your servlets are loaded and initialized when the web application is installed, rather that waiting for the first request for the application.

Example

To configure the server to load servlets when a web application is installed, add the following line to the server.xml configuration file or a file that it includes:
<webContainer deferServletLoad="false"/>
This setting applies to all web applications installed in the server.