Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Primitives in Session

 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Can we store any primitive type variable (for eg - float,char,int ) in Session scope ?
Waiting for a reply
Thanks
 
Patil Niteen
Ranch Hand
Posts: 48
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Abhay,

HttpSession interface has methods to store and retreive the objects from session scope.The methods are:
setAttribute(String name, Object value)
Object getAttribute(String name)

If you want to store the premitives in the session scope you have to wrap them into corresponding object types and retreive the values by casting the return values.
For example, int values can be wrapped into Integer object and stored .

Hope this helps.

Thanks and Regards,
Nitin.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic