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");