• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class implementing multiple listeners

 
taash mg
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
how would one describe a class implementing multiple listner interfaces in the dtd of the application.. any ideas ..?
Cheers
taash
 
R K Singh
Ranch Hand
Posts: 5384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you define only class name for listeners in dtd file, servlet container take care of finding the listeners and send appropriate events.
HTH
CMIW
 
Jerson Chua
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will the container use the same instance or it will instantiate a new object for each type of listener?
 
Hanumant Deshmukh
Author
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container creates only one instance for each of the listener classes registered using the <listener> element. If such a class implements multiple listener interfaces, the container uses the same instance for notifying the events corresponding to all the interfaces that the class implements.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you actually want to have separate instances, then you'll probably need to use the "empty subclass" technique:

So that the Servlet Container treats them as separate classes.
 
rajesh karmani
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I am not clear abt this empty sub-class technique. Why do we use it and what does it actually achieve? Though i agree with hanumant that only instance is create per listener tag in web.xml. If it implements multiple interfaces then it is automatically handled by the container.
Rajesh Kumar
SCJP2,SCWCD, UML(486), J2EE(483)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic