I'm trying @Inject
a @SessionScoped
bean in Filter
@WebFilter("/*") public class IdentityFilter implements Filter, Serializable { @Inject private LoginUser loginUser; ...
where LoginUser
is @SessionScoped
It is assumed that loginUser will represent the registered user for the session.
The problem is that I do not always get LoginUser
from the current session, I get a "leak" between sessions, since there is one session. The LoginUser object is sharing with another session. Obviously, this is not good.
I am wondering if this is because the Filter
object is singleton or at least reused between requests and sessions using a container (glass fish). (Right?)
Is there a better way to get the LoginUser
object for the current session without using the property in Filter?
source share