Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Order of loading of web.xml components/elements

 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have faced this question often in some mocks I had taken which asks about the order of loading that takes place for the different components.

Please tell me the order of class loading / instantiation which happen after a web application is deployed for all components / elements which can come in the web.xml (like servlets, listeners, filters, tags etc etc )

And one more question I have is does this order depend on the way the web.xml is written or is there a pre defined order which is fixed irregardless of the container?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I paste the specification's relevant part, which should answer both questions :

SRV.9.12 Web Application Deployment
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.
� 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.
 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Satou,

I should really read the specification I guess.

But what about the tag handler classes and tag files? When are they instantiated?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At run-time, tag handler instances will be created and methods will be invoked in them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic