I am trying to get a sublist List, but I want the sublist to be serialized. I found out that when we get a sublist from ArrayList, the sublist is not serialized.
To overcome this, this is what I do:
ArrayList serializedSublist = new ArrayList();
//getQuestions() returns RandomAccessSubList
getQuestions().addAll(serializedSublist);
//problem is in the line below. serializedSublist is empty.
getRequest().getSession().setAttribute("questionsForUser", serializedSublist);
The problem is that it is serializedSubListempty on line 5, but on line 3 the getQuestions()list goes back.
source
share