HI,
There are many ways to get the bean instances from the JSF context. In the following two way:
Bean bean = (Bean) request.getAttribute("beanName");
and
FacesUtils.getManagedBean("beanName");
What is the difference in above two ways. In which case we have to use either ways. Please clarify me.
Use the first if you’re not inside the JSF context (aka the
FacesContext), e.g. inside a servlet. The second way is unclear sinceFacesUtilsis not part of standard JSF implementation (it’s likely a homegrown or 3rd party library). But if it grabs it by theFacesContext, then it works only when you’re already inside the JSF context (i.e. inside a JSF managed bean).