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 51898 articles. 38 followers. Post

1 Replies
291 Views

Similar Articles

[PageSpeed] 51


  • 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 one class from another class
Hello, All. I'm trying to consuming an xml file and map it to a Ruby object that would describe that xml file. What would be the best way to implement the following scenario. Let's say I have several classes: Student, Course, Person, Tuition Xml for this would look like this: <Record> <Student status="good"> <Person> <Name>Alice</Name> <BirthPlace>WonderLand</BirthPlace> </Person> <Course difficulty="> <CourseName>Math III</CourseName> <Grade>B+</Grade> </Course>...

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) >...

Could an instance of a small class as a member of a bigger class access the bigger class's static variable?
I am making a simulation program in which I constructed 2 classes. A small one which describe a single atom (cls_atom), and a large one, which is the container of the simulation containing lots of atoms (cls_box). Therefore cls_atom will create thousands of instances as member of cls_box. Now there are lots of member variables of the cls_box needed to be shared by all instances of cls_atom. For example, temperature T, pressure P and total volume of the box, V, which is the global parameter for the sandbox and should be accessed by all atoms. Is there a way to authorize such access...

why a class can't access protected method from another class in the same package,the method is interited from the ohtner class from differnt package?
package XX;class A{ protected void kk ();}package YY;import XX.A;class B extends A{}package YY;class C{ public void zz() { kk(); //why can call B.kk()???? }}but if we modify as below:package YY;import XX.A;class B extends A{ protected void kk () { super.kk(); }}why above modify can success?3ks <junzhang1983@gmail.com> wrote in message news:92be769e-b993-4daf-9c86-8252f5e83807@s12g2000prg.googlegroups.com...> package XX;> class A> {> protected void kk ();> }>> package YY;> import XX.A;>> class B extends A> {>&...

How to access a class member function outside of its class?
Being a newbie in C++ and comming from C, I can't find information on how to access a class member function outside its class. Below is a snippet of the class and its member function: look at "AddCallPages" ============================================================= class CPsnstatuspttView : public CFormView { protected: // create from serialization only CPsnstatuspttView(); DECLARE_DYNCREATE(CPsnstatuspttView) public: //{{AFX_DATA(CPsnstatuspttView) enum { IDD = IDD_PSNSTATUSPTT_FORM }; CEdit m_edit_msgs_ctrl; CString m_edit_messages; //}}AFX_DATA // Attributes publi...

Classes in a class: how to access variables from one in another
Hello. I have a class A that contains two classes B and C: class A: class B: self.x = 2 class C: Is there a way to access the x defined in B in class C? Thanks. -- F. Delente On 2010-10-18, <fab@slick.airforce-one.org> <fab@slick.airforce-one.org> wrote: > Hello. > > I have a class A that contains two classes B and C: > > class A: > class B: > self.x = 2 > > class C: > > Is there a way to access the x defined in B in class C? That's not valid Python code. Do you mean: Class A: Cl...

JNI accessing a class that instantiates another class
I'm taking my first stab at JNI. I have a main Java class that instantiates another class. In my C++ code, I am using the FindClass function for the main class and calling the method in the main class using GetStaticMethodId/CallStaticIntMethod. The C++ code is successfully finding the Java class and calling the method that I specified in the GetStaticMethoId function. The only problem is, when the Java class attempts to create an instance of this second, inner class, it dies. I don't get an error, it just doesn't work. My question is... Do I need another FindClass statement ...

How to access outer class attribute from nested class
Please see the following example. Is there any other way to access SomeAttribute from the nested class, without having to use the actual name of the outer class? class SomeClass: SomeAttribute = 1 class SomeNestedClass: SomeOtherAttribute = 2 def SomeNestedClassMethod(cls): print "%s%s" % ( SomeClass.SomeAttribute cls.SomeOtherAttribute, ) SomeNestedClassMethod = classmethod(SomeNestedClassMethod) Thanx I use something like: class SomeClass: SomeAttribute = 1 class S...

Accessing class variable at class creation time
Hi! class A: X = 2 def F(): print A.X F() The above fails because the name A is not yet at global scope when the reference A.X is reached. Is there any way to refer to A.X without making explicit use of the name 'A'? Admittedly the code looks pretty unusual, but I'm defining configuration "minilanguages" to configure different parts of an application, each inside a configuration class (like A), and I find this very convenient except for the above problem. Thank you in advance Regards, Carlos You could use self.__class__.X HTH, Ole 23 Sep 2005 14:01:21 -0...

how to access object of one class in another class
i am having problem in JDBC.there are two different class within same packa= ge name.one class is dbconnect and another is login. I need to call the dbc= onnect class within login class and i need to call the connection object fr= om the dbconnect class in the login class. Please help me On 02/20/2013 04:04 AM, xodepp shrestha wrote: > i am having problem in JDBC.there are two different class within same package name.one class is dbconnect and another is login. I need to call the dbconnect class within login class and i need to call the connection object from the dbconnect class in ...

Customizing class attribute access in classic classes
Hi, I'm wondering if there is any way to customize class attribute access on classic classes? So this works: class Meta(type): def __getattr__(cls, name): return "Customized " + name class A: __metaclass__ = Meta print A.blah but it turns A into a new-style class. If "Meta" does not inherit from type, the customization works but A ends up not being a class at all, severely restricting its usefulness. I then hoped I could get "Meta" to inherit from types.ClassType but that wasn't allowed either. Is there any way to do this or is it j...

Access instance of one class from another class
Consider the following situation. I have a class called Node with properties Xcoordinate and Ycoordinate. I instantiate a vector "nodes" of length "nnodes" that stores the x and y coordinates for these nodes. Now I want to construct another class called Link that has a node at either end. The properties of this class stores the index of the nodes that are the end points of this link and some other dependent properties. classdef Link properties EndNodes = [0 0]; end properties (Dependent=true, SetAccess=true) DepProp1 DepProp2 end methods function link = Link(varargin) % ...

Accessing derived class members from base class
I am into c++ code maintenance for last 3-4 years but recently I am put into design phase of a new project. Being a small comapany I dont have enough guidance from seniors. Currently I am into a situation where I am implementing base class functions by including a pointer to subclass member in base class. Reason being functionality is common for subclasses but the members are common within subclass only (static member of subclass) but vary across different subclasses. I am confused is it a godd design decision or there is another alternative to this. If anybody can provide me details of sit...

matlab class should listen to events from java class! possible?
Hallo, i have following problem: I use small java API as jar in matlab. It works fine. I can instantiate and use the classes. One of the java classes fires events. I would like to forward the event information to the apropriate Matlab class. I can implement this scenario using matlab classes using event listeners and notifiers. But ist this possible to do it directly from java class to matlab class? Does enybody has an idea? An example would be great. Thanks Joe "joe " <b574988@tyldd.com> wrote in message <i0ptbk$6sn$1@fred.mathworks.com>... > Hallo, > >...

Does an outer class have access to private elements of its inner class?
My experimentation seems to say yes, but I can't seem to find itexplicitly stated so anywhere. Dural wrote:> My experimentation seems to say yes, but I can't seem to find it> explicitly stated so anywhere.Its stated in the JLS, 6.6.1 Determining Accessibility, "Otherwise, ifthe member or constructor is declared private, then access is permittedif and only if it occurs within the body of the top level class (�7.6)that encloses the declaration of the member or constructor."http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.6.1Note that it says "body o...

Simple Newbie question about accessing a Variable out of a class of a class
Hi After compiling "Hello World", I am on the way to code a shared library - but now I have some trouble. I have a class which is holding a Database connection. In this class there are other classes holding data from sql statements. For now I cannot access the connection object in the classes of the "connectonholding"-class, which is what I need. Here I paste my code and marked the sentence where the problem is, probably you can better imagine what I want. Thanks for your Help! Christian Maier //foo.h #include <pqxx/pqxx> using namespace PGSTD; using namespace p...