Search code examples
javajsfservlet-filtersphaselistener

How to run a PhaseListener before all Filters?


I have a phaseListener and more then one filter. I want to know if there is a way to create priority. I want phaseListener will be first and then all the filters. I am using the url mapping /* in web.xml for my filters.


Solution

  • I want phaseListener will be first and then all the filters.

    That's not possible. The phase listeners are to be executed by the JSF faces servlet. However, by specification the filters are invoked before any of the servlets. You'd need to revise your approach. Apparently the phase listener actually needs to be a filter. This is quite good possible if you are not dependent at all on the faces context. The filter mapping can then just be placed in front of all other filter mappings in web.xml.