wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes servlet life cycle mixed with listeners and filters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "servlet life cycle mixed with listeners and filters" Watch "servlet life cycle mixed with listeners and filters" New topic
Author

servlet life cycle mixed with listeners and filters

Shiang Wang
Ranch Hand

Joined: Jun 20, 2003
Posts: 96
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.



Thanks


SCBCD, SCWCD, SCJP
danny liu
Ranch Hand

Joined: Jan 22, 2004
Posts: 185
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.

So the correct sequence is 1,4,2,3.

Dan
Omar Dziri
Greenhorn

Joined: Oct 06, 2004
Posts: 20
Hi,

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.


Master degree in computer systems,<br />SCJP 1.4,<br />SCBCD 1.3,<br />SCWCD 1.4,<br />SCDJWS(in progress)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet life cycle mixed with listeners and filters
 
Similar Threads
Can anybody answer this question?
Please answer me this question.
Doubt on Session Attribute and Web Deployment
Passed SCWCD with 94% - My two cents
SCWCD - need answers to these questions.