The load on startup servlet

If you want your servlet to be initialized when the server starts, then this is what you need. Usually you will use it to load some cache, start a background process, log some information, or whatever you need to do when the server has just started and can't wait until somebody calls the servlet.

The key points of this kind of servlet are:

  • The loadOnStartup param: Accepts any number of servlets. This number defines the order used by the server to run all the servlets that will run in the startup. So if you have more than one servlet running this way, remember to define the right order (if there is any). If there's no number defined or a negative one, the server will choose the default order.
  • The init method: Remember to override the init method with the operation you would like to do at the start up time, otherwise your servlet will do nothing.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.35.194