-1

I'm trying to guarantee the order of the init method calls on a couple of servlets. My thought is to specify a load-on-startup value of 1 for the first servlet I want to initialize and a value of 2 for the load-on-startup value of the second servlet I want to initialize.

My question is what happens if I get a request for servlet 2 before the servlet 1 initialization completes?

Hi Jarrod, I don't believe my question was a duplicate. Thanks, Charlie

Charlie
  • 23
  • 2
  • Clarification please: Where does the answered question above indicate no requests to any servlet with load-on-startup are serviced until the completion of load-on-startup for all servlets with load-on-startup? – Charlie Aug 15 '17 at 20:39

1 Answers1

-1

A request will not be handled by a web application before the web application has started up. If you specify a non-negative load-on-startup value, it means that the servlet init() method invocation will occur during the web application startup. As a result, such a servlet will not handle any request until its init() method has finished.

So servlet container will call init() on servlets with non-negative load-on-startup (in order) and only then it will allow them to handle requests.

Tomcat 7 with default configuration delays requests received during the application startup (at least, in my case).

More information on Tomcat specifics in the answer to Prevent Tomcat from caching request during starup

Roman Puchkovskiy
  • 11,415
  • 5
  • 36
  • 72