Perhaps you can use the session getLastAccessedTime() and flush out "semi-old" objects as needed. That is, maybe your overall session timeout is 30 minutes. But on a request you could look at the session and check to see if it has been accessed within the last 15 minutes. If so, you would toast the objects that you want. This could be done in a Filter which would then be transparent to your servlets. Just a thought.
Originally posted by Michael J. Makunas:
Is there a way to make objects that are stored in the session "expire" after a set amount of time even though the session is still valid? I know I could add some sort of time stamp to the data structure and check that timistamp the next time I retrieve the object from the session. What I really want is for these objects to remove themselves after a certain amount of time.