• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Listener invocation order

 
Greenhorn
Posts: 16
1
Netbeans IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 : https://coderanch.com/t/510516/Servlets/java/listener-DD#2308293

Thanks in advance.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic