I have a problem with my program.
I have a servlet; in this servlet save the session attribute
ArrayList<Integer> list = new ArrayList<Integer>;
list.add(1);
request.getsession().setAttribute("list",list);
Now the attribute is a String and not an ArrayList. In fact when i try to do:
request.getsession().getAttribute(list)
is a string and not an Array.
I want an Array.
Thanks
You have to cast when you get the attribute from the session like this:
ArrayList<Integer> list = (ArrayList<Integer>)request.getsession().getAttribute("list");
And the attributes in the session are stored in a map, that is why the key you used is a String and you have to use a string to retrieve the value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With