I would like to inject CDI SessionScoped bean into JSP page.
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
@SessionScoped
public class UserSessionBean implements Serializable {
private String email = "email";
public UserSessionBean(){}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
When I use the bean this way it works fine and I see initial value on the JSP page.
<jsp:useBean id="userSessionBean" class="package.UserSessionBean"/>
<jsp:getProperty name="userSessionBean" property="email"/>
The problems occurs when I inject the same bean into a service which I call from some another servlet inside my API. In this case I don't get updated value at the JSP page. Looks like I get different beans in JSP page and inside the service using @Inject
annotation
Can anybody advise how it is possible to use the same SessionScoped bean inside JSP and service layer accessed from servlet?