Uncategorized

When to use in web.xml

25 Oct , 2016  

<load-on-startup> is suitable for those servlet which performs time consuming jobs e.g. Creating Database Connection pool, downloading files or data from network or prepare environment ready for servicing client in terms of initializing cache , clearing pipelines and loading important data in memory. If any of your servlet performs these jobs then declare them using <load-on-startup> element and specify order as per your business logic or what suites your application. Remember lower the value of <load-on-startup>, servlet will be loaded first. You can also check your web container documentation on how exactly load on start-up is supported.

Important points on load-on-startup element

  1. If <load-on-startup> value is same for two servlet than they will be loaded in an order on which they are declared inside web.xml file.
  2. if <load-on-startup> is 0 or negative integer than Servlet will be loaded when Container feels to load them.
  3. <load-on-startup> guarantees loading, initialization and call to init() method of servlet by web container.
  4. If there is no <load-on-startup> element for any servlet than they will be loaded when web container decides to load them.

     


Leave a Reply

Your email address will not be published. Required fields are marked *