aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes whether servlet of filter is instantiated first? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "whether servlet of filter is instantiated first?" Watch "whether servlet of filter is instantiated first?" New topic
Author

whether servlet of filter is instantiated first?

Loveleen Saroya
Ranch Hand

Joined: Aug 08, 2005
Posts: 42
whether servlet of filter is instantiated first?
can anybody give me a link related to it?

thanks in advance
Loveleen Saroya
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

I don't think any instantiation order of servlet and filters. The server/filters must loaded before exeucution of it's service/doFilter method.

We can define <load-on-statup> in DD to load the servlet at the start of the servlet.


Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Sai Patnala
Ranch Hand

Joined: Jan 09, 2002
Posts: 60
Here is what the specification says:

When a web application is deployed into a container, the following steps must be
performed, in <b>this order</b>, before the web application begins processing client
requests.
� Instantiate an instance of each event listener identified by a <listener> element
in the deployment descriptor.
� For instantiated listener instances that implement ServletContextListener,
call the contextInitialized() method.
� Instantiate an instance of each filter identified by a <filter> element in the deployment
descriptor and call each filter instance�s init() method.
� 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.


So filters are instantiated before Servlets.


SCJP2, SCWCD 1.4
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi Sai,

Thanks for the valuable information. I missed it while reading the specifications as I skipped the ch 9. I was thinking that the container have map of all resources while loading the applicatin and it instantiated the listeners and filters as n when required to avoid the memory usage.

But the specs are very clear.

Thanks again.
[ November 18, 2005: Message edited by: Narendra Dhande ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: whether servlet of filter is instantiated first?
 
Similar Threads
Servlet Lifecyle
Servlet loading
Passed SCWCD with 94% - My two cents
what happens when Filter and Servlet mapped to same url-pattern
servlet startup order