In my app I created an ArrayList in some servlet which was assigned using request.setAttribute() as 'testList'. Then request was forwarded to jsp page. Inside jsp page I want to retrieve whole ArrayList and iterate over it.
I used getAttribute(), but after that I cannot retrieve an ArrayList from that object.
An ArrayList contains objects TestObject created by me in another class (which was imported properly). I would like to get access to it by iteration over ArrayList.
Object testList = request.getAttribute("testList");
ArrayList<TestObject> localList = new ArrayList<TestObject>();
localList = testList;
//Type mismatch: cannot convert from Object to ArrayList<TestObject>
What is a best practice to obtain data from Object to ArrayList?
Should I use a cast (IDE warns: Type safety: Unchecked cast from Object to ArrayList)? Or generics? Or... ?