Reputation: 12003
It seems to me that "session" scope is another means to keep objects in session as
using setAttrubute / getAttribute
Correct?
You know, dont know why, it does not work for me.
<bean id="sabreUser" class="util.MyUser" factory-method="getSomeUser" scope="session">
<const args...>
What I see is that after the initialization and initial deploy the MyUser properties are correct.
Then, in the first session I change MyUser property, the session is closed.
The second session runs and it sees the last set value from the previous session!
What does that mean?
I expect this object to be initialized whenever a new session starts. But it better looks as singleton, though you see - "session" attribute is set.
I can see the cause of the problem in that a Servlet's fields is initialized with @Autowired so, once it is initialized, every other session will see its fields set and does not "ReWire" this properties. It happens once? How to overcome this problem?
Upvotes: 0
Views: 9116
Reputation: 1036
Session scoped beans are stored in Http Session by Spring framework. This scope is valid only in the context of Web application.It also works for Portlet envionments . When using in Portlet environment, there are two notions of session, application scope and portlet scope (default).
Upvotes: 1
Reputation: 2480
The Spring session does not exactly match the HttpSession, and even the Spring documentation on the @SessionAttributes annotation says that it might be stored in the session or "some conversational storage". I got that from The Spring docs for 2.5 I've basically quit trying to make sense of it, and just got on with my life, if I want something stored in the HttpSession, I just have Spring inject the HttpSession to me, assuming you're using Spring MVC its pretty easy, instructions on the same page.
Upvotes: 1
Reputation: 597016
Session-scoped beans are beans that live throughout the http session. They are stored in the session via setAttribute
in some way.
So - yes.
Upvotes: 1