You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Craig Longman <cr...@begeek.com> on 2002/09/10 19:55:42 UTC

Managing a Listener

i have a need for some data that is needed by every page.  Ideally, this
would simply be a class that is shared by everything else in one webapp
subdirectory, and available in the page context or session.

the only way i can see to do this (based on the docs at least) is to
configure a Listener to look for new session evens, and store an object
in the session that can be used to access the information.

however, i would definitely want this listener to be able to read init
information and find the preferred logger, etc.

how is this accomplished?  the listener, although configurable from the
server.xml file, seems to receive no config information.  it needs to
have things like a configuration file name passed to it.

the other way i guess would be to split up the thing into two
(conceptually at least), one listener and something else that gets
initialized by the container.  would that have to be a servlet then?  is
there any way of just initializing 'objects' in server.xml?

-- 

    CraigL->Thx();
    Be Developer ID: 5852


RE: Managing a Listener

Posted by "Sexton, George" <gs...@mhsoftware.com>.
This has already been said, but use a properties file. If you ever have more
than one instance, dealing with the XML files is very painful.

-----Original Message-----
From: Craig Longman [mailto:craigl@begeek.com]
Sent: 10 September, 2002 12:57 PM
To: Tomcat Users List
Subject: RE: Managing a Listener


On Tue, 2002-09-10 at 14:53, Sexton, George wrote:
> Why not create a singleton class to hold the information?

this is, in effect, what it would be (i imagine there is only one
filter/listener created, but i'm not sure).  but INITIALIZING that
information is what i'm trying to figure out, i want it to be configured
from the server.xml file as much as possible, hard-coding things always
seems to cause problems at some point.

> -----Original Message-----
> From: Craig Longman [mailto:craigl@begeek.com]
> Sent: 10 September, 2002 11:56 AM
> To: tomcat-user
> Subject: Managing a Listener
>
>
>
> i have a need for some data that is needed by every page.  Ideally, this
> would simply be a class that is shared by everything else in one webapp
> subdirectory, and available in the page context or session.
>
> the only way i can see to do this (based on the docs at least) is to
> configure a Listener to look for new session evens, and store an object
> in the session that can be used to access the information.
>
> however, i would definitely want this listener to be able to read init
> information and find the preferred logger, etc.
>
> how is this accomplished?  the listener, although configurable from the
> server.xml file, seems to receive no config information.  it needs to
> have things like a configuration file name passed to it.
>
> the other way i guess would be to split up the thing into two
> (conceptually at least), one listener and something else that gets
> initialized by the container.  would that have to be a servlet then?  is
> there any way of just initializing 'objects' in server.xml?
>
> --
>
>     CraigL->Thx();
>     Be Developer ID: 5852
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--

    CraigL->Thx();
    Be Developer ID: 5852



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Managing a Listener

Posted by Craig Longman <cr...@begeek.com>.
On Tue, 2002-09-10 at 14:53, Sexton, George wrote:
> Why not create a singleton class to hold the information?

this is, in effect, what it would be (i imagine there is only one
filter/listener created, but i'm not sure).  but INITIALIZING that
information is what i'm trying to figure out, i want it to be configured
from the server.xml file as much as possible, hard-coding things always
seems to cause problems at some point.

> -----Original Message-----
> From: Craig Longman [mailto:craigl@begeek.com]
> Sent: 10 September, 2002 11:56 AM
> To: tomcat-user
> Subject: Managing a Listener
> 
> 
> 
> i have a need for some data that is needed by every page.  Ideally, this
> would simply be a class that is shared by everything else in one webapp
> subdirectory, and available in the page context or session.
> 
> the only way i can see to do this (based on the docs at least) is to
> configure a Listener to look for new session evens, and store an object
> in the session that can be used to access the information.
> 
> however, i would definitely want this listener to be able to read init
> information and find the preferred logger, etc.
> 
> how is this accomplished?  the listener, although configurable from the
> server.xml file, seems to receive no config information.  it needs to
> have things like a configuration file name passed to it.
> 
> the other way i guess would be to split up the thing into two
> (conceptually at least), one listener and something else that gets
> initialized by the container.  would that have to be a servlet then?  is
> there any way of just initializing 'objects' in server.xml?
> 
> -- 
> 
>     CraigL->Thx();
>     Be Developer ID: 5852
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
-- 

    CraigL->Thx();
    Be Developer ID: 5852


RE: Managing a Listener

Posted by "Sexton, George" <gs...@mhsoftware.com>.
Why not create a singleton class to hold the information?

-----Original Message-----
From: Craig Longman [mailto:craigl@begeek.com]
Sent: 10 September, 2002 11:56 AM
To: tomcat-user
Subject: Managing a Listener



i have a need for some data that is needed by every page.  Ideally, this
would simply be a class that is shared by everything else in one webapp
subdirectory, and available in the page context or session.

the only way i can see to do this (based on the docs at least) is to
configure a Listener to look for new session evens, and store an object
in the session that can be used to access the information.

however, i would definitely want this listener to be able to read init
information and find the preferred logger, etc.

how is this accomplished?  the listener, although configurable from the
server.xml file, seems to receive no config information.  it needs to
have things like a configuration file name passed to it.

the other way i guess would be to split up the thing into two
(conceptually at least), one listener and something else that gets
initialized by the container.  would that have to be a servlet then?  is
there any way of just initializing 'objects' in server.xml?

-- 

    CraigL->Thx();
    Be Developer ID: 5852



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>