• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Order of filters which are programmatically added

 
Himai Minh
Ranch Hand
Posts: 1359
7
  • Mark post as helpful
  • send pies
  • 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?
 
Marcos R Oliveira
Ranch Hand
Posts: 62
1
  • Mark post as helpful
  • send pies
  • 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
Ranch Hand
Posts: 1359
7
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic