I have a CDI bean defined as following:
@Named("loginBean")
@SessionScoped
public class LoginBean implements Serializable {
@EJB
private LoginManager loginManager;
private String username;
private String password;
Now I want to remove it from session scope programmatically:
HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
LoginBean ins = (LoginBean)session.getAttribute("loginBean");
But the ins
variable is always null. How can I retrieve loginBean
instance and destroy it?