Meaningless Drivel is fun!*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Primitives in Session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Primitives in Session" Watch "Primitives in Session" New topic
Author

Primitives in Session

Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1076
    
    1

Hi
Can we store any primitive type variable (for eg - float,char,int ) in Session scope ?
Waiting for a reply
Thanks


Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I
Patil Niteen
Ranch Hand

Joined: Dec 10, 2009
Posts: 48

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.


SCJP 1.4, SCWCD 5
 
 
subject: Primitives in Session
 
Similar Threads
Alternative to Cookie?
Field set in action method coming null in JSP
Session problem in NetBeans
Advice on persisting complex state across multiple server trips
ASP