Using a Stateful Session Bean to track an user's session

后端 未结 2 1302
长情又很酷
长情又很酷 2020-12-01 01:25

it\'s my first question here and I hope that I\'m doing it right.

I need to work on a Java EE project, so, before starting, I\'m trying to do something simple and se

2条回答
  •  不思量自难忘°
    2020-12-01 02:29

    You need to define the bean with @SessionScoped instead of @RequestScoped (if you are looking for HttpSession equivalent solution)

    something like

    @SessionScoped
    public class SessionInfo implements Serializable{
       private String name;
       public String getName() {
          return name;
       }
       public void setName(String name) {
          this.name = name;
       }
    }
    

    Have a look at following (explained in detail)

    http://www.oracle.com/technetwork/articles/java/cdi-javaee-bien-225152.html

提交回复
热议问题