• 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

Order of filters which are programmatically added

 
Bartender
Posts: 2418
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
From the Servlet 3.0 spec, chapter 4, I don't see any specification about the order of the filters which are programmatically created.

(In DD, I know the order of the filter is defined based on the order in DD and those filters with <url> always comes before those filters with <servlet>)
How about those programmatically defined?
 
Ranch Hand
Posts: 62
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Himai,

Chapter 8 (8.2.3) states that

... As described above, when using
annotations to define the listeners, servlets and filters, the order in which they are
invoked is unspecified. ...



and also

1. The order for listeners, servlets, filters if relevant must be specified in either the
web-fragment.xml or the web.xml. ...



Best regards,
Marcos.
 
Himai Minh
Bartender
Posts: 2418
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In Charles Lyon's book, we can programmatically add filter, servlet, listeners in a ServletContextListener or SerlvetContainerInitializer by calling ServletContext's addFilter, addServlet , addListener methods.
But in this case, I don't see any order specified for filters.
 
Marcos R Oliveira
Ranch Hand
Posts: 62
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I see... but I think that for programmatically added filters the same rule applies:

1. The order for listeners, servlets, filters if relevant must be specified in either the
web-fragment.xml or the web.xml. ...



And you can even use <absolute-ordering> element in the web.xml and <ordering> element within the web-fragment.xml

Other than that, order for filter calling is unspecified.
 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic