Discussions

I'd like to know how to retain objects across requests. I tried using singleton classes, but I think values stored in a singleton class are accessible to all users. I need to retain objects that are specific to a particular user, across different calls by that user.

I am aware of how to use Stateful Session Beans to achieve this. This can also be done by serializing the object and persisting to the disc. But I am looking for a simpler solution. Any help in this regard is appreciated. Thanks in advance.

Just create an object in your servlet class that you instantiate in the init() method. However, be sure to synchronize the "write" access to this object. If you modify this object very often, this is not a good solution as it will create a bottleneck.

Sorry for getting back so late... Yes, using the Session is the most obvious way, but the Session memory has been limited to ONLY 2Kb per user for my application (!!!). So I cannot use that approach. Some people mailed me saying I could write out the values to hidden fields on the JSP and get them through the HTTP Request in my Action class (Btw my application uses Apache Struts). I cannot do this either because what I want to save, is an Object, not just a String. Hope I'm not bugging too you too much.

Yes, using the Session is the most obvious way, but the Session memory has been limited to ONLY 2Kb per user for my application (!!!). So I cannot use that approach.

Are you running in a clustered environment? If so, you may want to check out Coherence*Web for your HTTP session management. Coherence*Web allow for linear scalable performance of HTTP sessions with no single point of failure or bottleneck. Also, there is on limit to the size of the session object.

Nopes, Rob. Not a clustered envmt. Standalone IBM WebSphere App Server, if that makes any difference. I'm currently doing away by serializing and writing the object into a temporary DB table. But I'd be glad to know anything better.

TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations technology projects - with its network of technology-specific websites, events and online magazines.