In my Spring MVC project I have a jsp page , registration page , in which there is a form. In this form the user inserts his data (name, surname and so on).I created a bean User and I bound the form with this bean.But now I have a problem.How can i put the user object into a session in a method of a controller?
Can I use @SessionAttributes
,httpsession or I set the scope of the bean to session? How can i solve it?Sorry for my English. Thanks
Asked
Active
Viewed 613 times
0

Harshal Patil
- 6,659
- 8
- 41
- 57

Alex
- 2,075
- 5
- 27
- 39
-
So u need to set user object in session? – Harshal Patil Nov 27 '14 at 17:32
-
I don't know if it's better to set user object in HttpSession, or to set the object in @SessionAttributes or to set the bean as scope=session – Alex Nov 27 '14 at 19:19
1 Answers
1
You can use HttpSession
so just need to set your user object in your session and access anywhere into the system.
Refer this httpsession documentation for setting session value.

Harshal Patil
- 6,659
- 8
- 41
- 57
-
-
@SessionAttribute does not have to use the http session. It uses a SessionAttributeStore which can have anything as its backing storage. Only the default implementation uses the httpsession. – Harshal Patil Nov 28 '14 at 04:36
-
So, if I want to put something into the session it's better that I use an http session? What's the differences between http session and SessionAttributeStore?So, if I want to put something into the session it's etter than I put it into an http session? – Alex Nov 28 '14 at 09:45
-
-
Sorry, but if i create a bean with scope session , Spring put it into http session? – Alex Nov 28 '14 at 10:12
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/65820/discussion-between-harshal-patil-and-alex). – Harshal Patil Nov 28 '14 at 10:20