Search code examples
htmljsf-2unauthorizedphaselistener

How to activate phaselistener when HTML5 file is called in JSF


I define a PhaseListener in JSF project. It is working when *.xhtml file is called in browser. But It is not working when *.html5 file is called in browser. Can do I do phaseListener for?

If I can not this check, What can I do instead of phaseListener?


Solution

  • Use a servlet filter instead.

    Here's a basic kickoff example:

    @WebFilter("*.html5")
    public class MyFilter implements Filter {
    
        @Override
        public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
            // Perform here some code before processing the request.
            // ...
    
            chain.doFilter(req, res);
    
            // Perform here some code after processing the request.
            // ...
        }
    
    }