Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Listener invocation order  RSS feed

 
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.
 
Rancher
Posts: 43009
76
  • 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!
 
I can't renounce my name. It's on all my stationery! And hinted in this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!