Ashish Kumar Shah
Ashish Kumar Shah

Reputation: 532

How to initialize a webapp in Tomcat only when the servlet is requested

I have a tomcat webapp which has a dependency on another application (which will mostly not have started up when tomcat starts), so my initialization fails.

I want to know if there is a way to skip the initialization of my webapp at tomcat startup and initialize it only when my servlet gets a request.

Upvotes: 1

Views: 567

Answers (3)

Som
Som

Reputation: 864

load-on-startup Tag facilitate the servlet to preinitialization just remove the tag you will get lazy loading which you want

Upvotes: 1

Sajan Chandran
Sajan Chandran

Reputation: 11487

By default your servlet will be initialised only when its first invoked, unless you stated otherwise in your web.xml using load-on-startup parameter.

Upvotes: 2

Don't set load-on-startup. Alternatively, you can set load-on-startup for the dependent servlet to a higher value than that of the servlet it depends on to ensure that they'll be started in order.

Upvotes: 0

Related Questions