I have some bean using the @WebServlet
annotation:
@WebServlet("tools/httpProjectLoader.xhtml")
public class HttpProjectLoader extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
...
}
}
I want to use that URL to react on links from emails, for example:
http://myhost/webapp/tools/httpProjectLoader.xhtml?pn=1000000654
The web.xml uses the following setup for the FacesServlet
:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
When I try to access FacesContext.getCurrentInstance()
from within #doGet(...)
the returned value is always null
. Why? And how can I handle this? I want to use some UI (CDI) beans to init the application and forward to a resulting page. Whenever some code uses i.e. FacesContext.getCurrentInstance().addMessage(...)
it fails with a NullPointerException
.