f



tomcat :: Listener for my own class (global access to class)

hiI have one servlet with init() method which initialize object of myown class.that's ok if I use this object from only one servlet.but how change it - add Listener and have access to object from allservlets.moreover do not edit any of tomcat files, only project files.thanks
0
devphyl (26)
9/26/2007 8:28:19 PM
comp.lang.java.programmer 52633 articles. 0 followers. Post Follow

1 Replies
489 Views

Similar Articles

[PageSpeed] 11

devphylosoff <devphyl@gmail.com> said:>I have one servlet with init() method which initialize object of my>own class.>>that's ok if I use this object from only one servlet.>but how change it - add Listener and have access to object from all>servlets.Your init() places the object to application context, so it will beavailable through application context to all other servlets needing it;just take care that the servlet initializing this class is somethingthat it loaded on webapp startup (web.xml init-on-startup, if I recallcorrectly).-- Wolf  a.k.a.  Juha Laiho     Espoo, Finland(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++"...cancel my subscription to the resurrection!" (Jim Morrison)
0
Juha
9/29/2007 8:37:03 PM
Reply: