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

  • Permalink
  • submit to reddit
  • Email
  • Follow


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
Reply devphyl (26) 9/26/2007 8:28:19 PM

See related articles to this posting

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
Reply Juha 9/29/2007 8:37:03 PM
comp.lang.java.programmer 51678 articles. 37 followers. Post

1 Replies
239 Views

Similar Articles

[PageSpeed] 52

  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Access classes in Tomcat
Hallo everybody In Tomcat (Version 5.0) jsp files are usually placed under /webapps/[myWebApplication]/ . Under /webapps/[myWebApplication]/Web-INF/classes/ I have all my java classes. How can I access this classes from my JSP-File? Thanks Peter Peter H=F6ltschi wrote: > How can I access this classes from my JSP-File? Copying from the top of a .jsp I find somewhere on the disk: <%@ page language=3D"java" import=3D"jada.jada.*, java.util.*, more.stuff.*"%> Hope this helps. Harald. ...

Is it possible to have globally accessible classes?
Hi all, I'm fairly new to java and OOP in general so i'm sure there will be a simple answer to my question, I just can't seem to find anything on google. The problem is I have a class called 'Server' and a class called 'ServerConfiguration', along with several other classes. In the main method of the Server class I create a new instance of ServerConfiguration passing with it the url of the config file. The problem comes when I want to use this instance of the ServerConfiguration class in other classes. I don't want to declare another instance in each class as ...

global variables accessed through multiple DLL class instance.
Hi, my problem is quite complexe to describe but here is a try : I have a C++ library exporting a class which is wrapped using a C++ ..Net Wrapper to be used in a C# software. In the C++ library I have a file which contains C functions in which there are global variable and pointers (it's not my code) and the C++ class access the C functions for some processing. My C# application is multithreaded and I instanciate two classes exported from the DLL which can be used concurrently. My question is : Sometime it crashes and I suspect that the problem is that the C global variables are uniqu...

How to I access a logging class from any other class.
I want to be able to write log data. How can I access my logging class from any class in the app, without passing a reference to it? SH Responding to Ssg31415926... > I want to be able to write log data. How can I access my logging class > from any class in the app, without passing a reference to it? I'll assume you only have one instance of the logging class. First let me point out that implementing relationships by passing objects is usually not a good idea. The problem is that conceptually one has: R1 R2 [Client] --------- [Service1] ----...

accessing Class from class symbol
Hi, I'm trying to work out how to access Class methods when I only have the class symbol class Foo def Foo.hello puts "Hello Foo" end end class Bar def Bar.hello puts "Hello Bar" end end str="Foo" # I could do this, but there must be a better way. eval "#{str}.hello" Kernel doesn't have send, so I can't pass the class as a symbol to Kernel, and then send the method. Any ideas? Cheers Steve "treefrog" <stephen.hill@motorola.com> writes: > Hi, > I'm trying to work out how to access Cl...

Where to save classes? How to access classes?
Hi, I'm trying to get into the object oriented aspect of Python. If I create a custom class (in it's own file), how do I access that class in a function in a different file? In Java there's the notion of a CLASSPATH, where you can tell the compiler to look for classes. Is there something similar to this in Python? Thanks, Dave David Mitchell wrote: > Hi, > > I'm trying to get into the object oriented aspect of Python. If I create > a custom class (in it's own file), how do I access that class in a > function in a different file? In Java there's t...

Base Class Accessible Accessible As Type Via Derived Class
Hi All, I am trying to locate the specific documentation in TCPPPL 3rd Ed. that says that a class is a scope, and applying the scope resolution operator allows access to types from that scope. Consider: template <class Element> struct Base { Element element; } ; struct Derived : public Base<int> { Base b1; // <int> unnecessary Base b2; // <int> unnecessary } ; First, I can no longer find the page that says that specification of <int> is unnecessary, as there is no ambiguity in type of Base. Furthermore: struct Big { ...

accessing class variables of private classes
Hi, I need to access class variables of a class I'd like to make private: i.e. class __Bar(object): pass class __Foo(__Bar): def __init__(self): super(__Foo, self).__init__() >>> __Foo() Name Error: global name '_Foo__Foo' is not defined Here I want to prevent the user of instanciating __Foo from outside of the module. i.e. class __A: a_list = [] def __init__(self): __A.a_list.append(self) >>> __A() NameError: global name '_A__A' is not defined Here I want to keep a list of instanciated objects of class __A, so I can update interna...

Access from one class to methode of other class
Hi, all! In my programm i have to insert a variable from class 2 to class 1 and I get error NameError: global name 'd' is not defined. How do I get access to d.entry.insert() method of class 1 class 1: self.entry = Entry(self.entryframe) self.entry.pack() self.button = Button(command = self.callclass2window) def callclass2window c = 2() class 2: def ins(self) d.entry.insert(variable) d = 1() I don't know if your're actually calling the classes '1' and '2', but that's a really bad idea! > class 2: > def ins(self) >...