archonLing
发贴: 57
积分: 10
|
于 2003-06-08 14:02
One problem with using hidden variables is that you can't store java object directly as a hidden variable and they are not so secure.
I saw a creative way to better manage session objects. Instead of directly storing data in session object, a named HashMap object, for example, "DataCache", is created as the central storage in session. All storing & removing of cross page data objects are done through "DataCache".
So, in this case, you can store the Page 1 data in DataCache. Then, retrieve them through DataCache on Page 2. If Page 3 is chosen, then the Page 1 data is retrieved from DataCache. Otherwise, you would have the option to clear out all the cached objects at once through clear() or remove them one by one by using remove().
BTW, the reasons for choosing HashMap are : 1. HashMap is a java Collection object, many build-in tools are provided; 2. HashMap is not syncrhonized, so it is faster.
|