Since Servlet and JSF are different container and JSF works on top of Servlet container. We will not be able straight forward inject it.Since all these beans are under sessions, We can use below approach to get Managed bean instance into Servlet
public class HelloServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { CustomerBean beanObj =(CustomerBean ) req.getSession().getAttribute("customerBean"); } }
Managed bean defined as below
@ManagedBean(name="customerBean") @SessionScoped public class CustomerBean implement Serializable { }
0 Comments
Post a Comment