Using a Session Scoped Bean

Posted by jboyd on Stack Overflow See other posts from Stack Overflow or by jboyd
Published on 2010-06-08T20:40:10Z Indexed on 2010/06/08 20:42 UTC
Read the original article Hit count: 303

Filed under:
|
|

The following code is returning null:

private MyAppUser getMyAppUser(HttpSession session) {
    MyAppUser myAppUser = (MyAppUser) session.getAttribute("myAppUserManager");
    return myAppUser;
}

Despite the fact that I have the following in my context:

<bean id="myAppUserManager" class="com.myapp.profile.MyAppUser" scope="session"/>

This doesn't make any sense to me, the "myAppUser" bean is a bean that absolutely can never be null, and I need to be able to reference it from controllers, I don't need it in services or repositories, just controllers, but it doesn't seem to be getting stored in the session, the use case is extremely simple, but I haven't been able to get to the bottom of what's wrong, or come up with a good workaround

© Stack Overflow or respective owner

Related posts about java

Related posts about web