ServletContextListeners are invoked in

ServletContextListeners are invoked in

ServletContextListeners are invoked in

A.
Random order

B.
contextInitialized and contextDestroyed are invoked in the order in which they are declared in the web.xml

C.
contextInitialized method are invoked in the order in which they are declared in the web.xml and the contextDestroyed method is invoked in the reverse order in
which they are declared in the web.xml

D.
contextInitialized and contextDestroyed are invoked in the reverse order of which they are declared in the web.xml

Explanation:
public interface ServletContextListener
extends java.util.EventListener
Interface for receiving notification events about ServletContext lifecycle changes.
In order to receive these notification events, the implementation class must be either declared in the deployment descriptor of the web application, annotated with
WebListener, or registered via one of the addListener methods defined on ServletContext.
Implementations of this interface are invoked at their contextInitialized(javax.servlet.ServletContextEvent) method in the order in which they have been declared,
and at their contextDestroyed(javax.servlet.ServletContextEvent) method in reverse order.



Leave a Reply 2

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