wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Listeners Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Listeners" Watch "Listeners" New topic
Author

Listeners

S.L.Narayanan
Ranch Hand

Joined: Apr 01, 2005
Posts: 431
Hi Friends

I know servlets to some extent but I am new to listener...My question is (may be very silly) if I want to add listeners to more than one event like ServletContextEvent and HttpSessionEvent and I have the listener classes in different files,then how can I declare both the classes in DD. Can I put 2 listener-class tags like



Or is there some other way?...Advance thanx...


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, NEXT--->IBM XML
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
You can add as many as you'd like.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Bhumika Thakkar
Ranch Hand

Joined: Apr 18, 2005
Posts: 79
but it should be

<!ELEMENT listener (listener-class)> *

u can have one and only one listener-class in listener.


SCBCD (Preparing) <br />SCWCD, 82%<br />SCJP, 90%
S.L.Narayanan
Ranch Hand

Joined: Apr 01, 2005
Posts: 431
Sorry Bhumika, I couldnt understand what u r coming to say ...Can u explain with a piece of code?...
Bhumika Thakkar
Ranch Hand

Joined: Apr 18, 2005
Posts: 79
if you have 2 listeners mySessionListener and myContextListener then in DD u would declare them as

<listener>
<listener-class>mySessionListener</listener-class>
</listener>

<listener>
<listener-class>myContextListener</listener-class>
</listener>

Notice that we have 2 separate listener elements. Its not 2 listener-class in one listener element.

Hope this makes it clear.
S.L.Narayanan
Ranch Hand

Joined: Apr 01, 2005
Posts: 431
Now I understood..Thanx for ur reply...
 
Don't get me started about those stupid light bulbs.
 
subject: Listeners
 
Similar Threads
How to write my own Event ( & Listener for it)??
Number of Instances
about listener
mistake in JavaDocs(JDK1.4) regarding Listeners
ContextLoader No log appenders found in Tomcat