How to register a JSF 1.2 PhaseListener in a Servlet.init()?

647 Views Asked by At

Is it possible? FacesContext.getCurrentInstance() returns null.

1

There are 1 best solutions below

2
On BEST ANSWER

A regular servlet isn't initialized/called during a JSF request, so there's no means of a FacesContext in a servlet. Only when the request URL matches the FacesServlet, then there's a FacesContext. You should register the PhaseListener in faces-config.xml or in a JSF managed bean instead. Consider doing it in the (post)constructor of an application scoped managed bean.