Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

session objects

Thread view: 
morc - 08 Feb 2006 18:54 GMT
hi,

i was wondering how to put an array of ints into an Object.

session.setAttribute(String,Object);

how can i make it so that i can retrieve whats in the attribute into an
array of ints.

meaning something along the lines of

int[] = session.getAttribute(String);

i know that code won't work. if anyone knows what i mean and can help
me, please post.
thanks alot
-morc
Dave f - 08 Feb 2006 19:00 GMT
Use an ArrayList of the Object 'Integer'.

Integer i1 = new Integer(1);
Integer i3 = new Integer(3);

ArrayList list = new ArrayList();
list.add(i1);
list.add(i3);

session.setAttribute(String, list);

...then...

ArrayList listFromSession = (ArrayList)session.getAttribute(String);

Then listFromSession is the ArrayList of Integer objects.

Actually, I think arrays are Java Objects, so just put your int[] array
into the Session using setAttribute() and when you do getAttribute just
cast to an int array.  I'm pretty sure that will work.
Manfred Rosenboom - 09 Feb 2006 10:44 GMT
Each array is also an object. So try the following code :

session.setAttribute("intArray", ia);

ia = (int[]) session.getAttribute("intArray");


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.