When we mention any servlet as loadOnStartup in web.xml then its init method is called for sure. Just wanted to confirm does service and destroy methods are also get called or not? If not when they get called?
Another question is as it is mentioned every where init method is called only once. Does that mean when the servlet gets the request first time, init method will be called and then service will be called.
But destroy will not be called. When the second request it will simply call the service method again but not init method. Is this understanding correct? But when container decides to call the destroy method?
loadOnStartupmeans that the servlet will be loaded (and itsinit(..)method called during container startup. Otherwise, as you suspect, it will be loaded when the first request comesinit(..). When the context is undeployed (for example – the container is stopped),destroy()is called