If your servlets are well-written, they should already not have any business logic inside, but just pure request/response controlling/preprocessing/postprocessing logic. The business logic should already be placed in standalone javabean-like domain/model classes. The database logic should already be placed in standalone DAO classes. And so on. You can just reuse them all in JSF.
That said, it may be good to know that JSF (when running on top of Servlet API --the common case) manages request scoped beans as attributes of HttpServletRequest
, the session scoped beans as attributes of the HttpSession
, the application scoped beans as attributes of ServletContext
. It may also be good to know that all of those request, session and application attributes are accessible by ExternalContext#getRequestMap()
, #getSessionMap()
and #getApplicationMap()
. You should now realize that you can just access them the usual way from inside a servlet.
In any case, when there is technical need to access the FacesContext
inside a Servlet
or a Filter
, then immediately stop coding it and rethink your approach based on the above facts. Shouldn't it better be done in a new managed bean? Or maybe a PhaseListener
?