My code is doing the following (just as an example, and the reason that I specify package path to java.lang.ref.SoftReference is to note that it's not my own implementaiton :-):
...
List<String> someData = new ArrayList<String>();
someData.add("Value1");
someData.add("Value2");
...
java.lang.ref.SoftReference softRef = new SoftReference(someData);
...
HttpSession session = request.getSession(true);
session.setAttribute("mySoftRefData", softRef);
...
and later:
...
java.lang.ref.SoftReference softRef = session.getAttribute("mySoftRefData");
if (softRef != null && softRef.get() != null) {
List<String> someData = (List<String>)softRef.get();
// do something with it.
}
...
Any disadvantages? Which I do not see? Thank you!