This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I got this question from jdiscuss.com, wonder if anyone can give me a correct question and short explanation?
Select the correct sequence of actions that a servlet container performs before servicing any request.
1. Instantiate listeners defined in the deployment descriptor. 2. Initialize filters defined in the deployment descriptor. 3. Initialize servlets that are set to load on startup. 4. Call the contextInitialized method on the listeners implementing ServletContextListener interface.
Listeners are shared by all applications and launched first. If one of the listeners is application listener then its contextInitialized method will be called to do some application-class initialization.
Filters are always launched before servlets cause they intercept servlets' requests and act as preprocessors.
When a web application is deployed into a container, the following steps must be performed, in this order, before the web application begins processing client requests. 1. Instantiate an instance of each event listener identified by a <listener> element in the deployment descriptor. 2. For instantiated listener instances that implement ServletContextListener, call the contextInitialized() method. 3. Instantiate an instance of each filter identified by a <filter> element in the deployment descriptor and call each filter instance�s init() method. 4. Instantiate an instance of each servlet identified by a <servlet> element that includes a <load-on-startup> element in the order defined by the load-onstartup element values, and call each servlet instance�s init() method.