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

D

devphylosoff

hi

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.
moreover do not edit any of tomcat files, only project files.

thanks
 
J

Juha Laiho

devphylosoff 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 be
available through application context to all other servlets needing it;
just take care that the servlet initializing this class is something
that it loaded on webapp startup (web.xml init-on-startup, if I recall
correctly).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top