I’ve registered an HttpSessionListener in my web.xml and it is working fine, however I need to access the object instance from other areas (for example Servlets) and would prefer to not use the old public static HttpSessionListener obj = this; (pseudo) pattern.
Is there a way to gain access to this object via the J2ee API?
I’m not sure why you want to access a session listener from a servlet.
It sounds like what you really want to do is refactor an object from the session listener, and access it via
ServletContext. Then it will be accessible from both the servlet and the listener.See the J2EE Tutorial for more information about scoped attributes.