I say APPARENTLY not loading/executing. It was first apparent simply from running the application (null values for attributes that the listener is supposed to initialize). When I try including a "hi it's me" system.out.println statement in the contextIntialized() code, I am finding it doesn't output to Tomcat's log, in this or any other case, though the same statements in my HttpSessionListener's do output to the log. Is this an expected result (system.out.println statements produce output for HttpSessionListener's but not ServletContextListener's) and, if so, why? I then tried writing out a physical file from within my contextInitialized() code instead, and that produces a file for all my ServletContextListener's except the case in point, which seems to confirm that that particular listener is not getting loaded/executed. So a secondary question is, what is the best way, at least in a Tomcat 5.x environment, for knowing that the listener is being loaded/executed (other than inferring this from the runtime results or from debugging via file output)?
A Container is required to locate all TLD files (see Section JSP.7.3.1 for details on how they are identified), read their listener elements, and treat the event listeners as extensions of those listed in web.xml.
The order in which the listeners are registered is undefined, but they are
registered before application start.
So, it should work.
If I get a chance, I'll play around this weekend with it and see what happens.
Originally posted by Bear Bibeault:
Oh, on re-reading your post. You are getting a listener to work -- just not the example you are trying to emulate?
Are any tags in the same TLD being loaded?
[ July 22, 2005: Message edited by: Bear Bibeault ]
Yes, I did get a listener declared in a TLD to work, just not the example from Marty's book. That listener worked fine too, when declared in the web.xml. And yes, the tag declared in the same TLD is working.
[ July 22, 2005: Message edited by: Randy Gibbons ]