Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Listener invocation order  RSS feed

 
Asif Pathan
Greenhorn
Posts: 16
1
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I was wondering if there is a way to be certain that listeners would be invoked in any specific order? Note that I am referring to servlet specification version prior to version 3.0. As per version 3.0, the ordering followed would be the one in web.xml (Reference: Servlet specification 3.0: Section 8.2.3). This section also says that prior to 3.0 the order of invocation is random.

Possible duplicate entry but reply does not match the specification text : http://www.coderanch.com/t/510516/Servlets/java/listener-DD#2308293

Thanks in advance.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By "random" the spec does not actually mean random, it means "unspecified" - I'm certain that each servlet container would use a predictable algorithm. I don't know that there is way to find out for sure what that algorithm is, short of examining the source code of whatever servlet container you're interested in, or running some tests with a number of listeners to get an empiric approximation.

but reply does not match the specification text

I don't think it would be accurate to say that, given that the post was made before Servlet spec 3.0 was finalized.

I also don't think that the order was unspecified prior to Servlet 3.0. For example, the Servlet spec 2.5 states (in SRV.10.3.3 and SRV.10.3.4) that the order of registration is the order of declaration in the DD, and that the order of registration is also the order of invocation.
 
Asif Pathan
Greenhorn
Posts: 16
1
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick and precise reply Ulf . Servlet specification version 2.5 is very clear with regards to the order, thanks for pointing out the relevant sections.

Cheers!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!