• Post Reply Bookmark Topic Watch Topic
  • New Topic

order of executions of listeners  RSS feed

 
Himai Minh
Ranch Hand
Posts: 1566
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to chapter 8.2.3 of servlet 3.0:

Prior to this release of the specification, context listeners were invoked in
random order. As of Servlet 3.0, the listeners are invoked in the order in which
they are declared in the web.xml as specified below:
i. Implementations of javax.servlet.ServletContextListener are
invoked at their contextInitialized method in the order in which they
have been declared, and at their contextDestroyed method in reverse
order.

ii. Implementations of javax.servlet.ServletRequestListener are
invoked at their requestInitialized method in the order in which they
have been declared, and at their requestDestroyed method in reverse
order.
iii. Implementations of javax.servlet.http.HttpSessionListener are
invoked at their sessionCreated method in the order in which they have
been declared, and at their sessionDestroyed method in reverse order.
iv. The invocation order for any of the other listener interfaces is unspecified.



So, according to this specification, does it mean all ServletContextListeners must be executed before all ServletRequestListeners and all ServletRequestListeners must be
executed before all HttpSessionListeners?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Posts: 2987
223
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I think this specifies the ordering per category. Not the categories themselves.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!