• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

whether servlet of filter is instantiated first?

 
Loveleen Saroya
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sai Patnala
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic