Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What's order in web container for starting up?

 
Grace Yang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have listeners, filters, servlets defined in web.xml and I'd like to know what's the order for instantiatons?


Is the order starting from listener--> filter-->servlet correct?

(I have print statement in my ContextInitializedI(), so I know each time when I modified web.xml , it output the statment in console,..)

anybody can help me ?

Thanks
 
Tiffiny Yang
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
listener--> filter-->servlet

any idea?
 
Grace Yang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any suggestion, any body knows?

Thanks
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good question. Even I'm interested in getting to know this!
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer to this can be determined simply by putting print statements into all those classes, can it not?
 
Mohit Chadha
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Per SRV 9.12 of Servlet Specification,

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.

I hope this answers your question.
 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember LCFS

LCFS means Listener -> ServletContextListener -> Filters -> Servlets
 
Grace Yang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it.

Thank you all of you!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic