This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Listeners

 
S.L.Narayanan
Ranch Hand
Posts: 431
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can add as many as you'd like.
 
Bhumika Thakkar
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but it should be

<!ELEMENT listener (listener-class)> *

u can have one and only one listener-class in listener.
 
S.L.Narayanan
Ranch Hand
Posts: 431
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Bhumika, I couldnt understand what u r coming to say ...Can u explain with a piece of code?...
 
Bhumika Thakkar
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 431
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I understood..Thanx for ur reply...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic