0

Currently I have a session scoped object called MySessionData. Originally when logging out I just called

getThreadLocalRequest().getSession().invalidate();

The problem is now we have multiple session scoped objects and logging out only really requires the ony (MySessionData) be cleared. Does anybody know of a way to clear a single Session scoped object in Guice. If this were using traditional session objects I would just set the key value pair to null in the session map.

benstpierre
  • 32,833
  • 51
  • 177
  • 288

1 Answers1

1

I usually use guice session objects as Holders. If you implements MySessionData like that, you just have to define a clear() method on it to remove or clear all the holded objects.

If it is not enough, you can still invalidate the session. If you need to keep a reference on the Session for this invalidation, you can use a ThreadLocal variable and set it using a ServletFilter.

GaetanZ
  • 2,819
  • 3
  • 21
  • 20