I have just recently merged in the issue... My results (not necessarily perfect :) are: - all listener objects are to be declared in web.xml; - it seems they are instantiated automatically along with the web app; - it may be a good idea to implement a listener as a special class, independent of any servlets; - a good servlet-to-listener communication point is ServletContext; - to arrange this communication a listener may implement also ServletContextListener and in its contextInitialized() register itself with the ServletContext using setAttribute (); - a servlet can then get reference to the listener via getServletContext().getAttribute();
The reason of your troubles (if I understood you correct) may be that you really have two servlet+listener instances. One is instantiated as listener an so its "init" is never invoked; the other is instantiated as servlet and does not get listener events. Regards, Sergey ----- Original Message ----- From: "Ralf Mitschke" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, June 12, 2002 2:41 AM Subject: Listener Objects > Hi! > > I would like to know how Listener Objects are instantiated. > > And here's my reason :-) > My Class extends HttpServlet and I tried to deal with SessionEvents in the same Class. > So I implemented HttpSessionListener. > But when the sessionCreated/sessionDestroyed methods get the Event any changes made in the Servlet are gone. > > For Example: I use a debuging Object of my own, which I instantiate in the Servlet init method. In sessionCreated the Instance is gone and the Reference is null. > > My Guess is that I am dealing with 2 different Object instaces. > Are the Listener Objects specified in the web.xml instantiated for themselves? > > If so, i could split the Class and encapsulate the session stuff I need to do in another Object. > But could you suggest a method to communicate between my servlet and my sessionListener? > > Thanks for your time :-) > > Ralf > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
