Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the need of writing <listener-class> in web.xml

 
jazy smith
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

why to write <listener-class> in web.xml ? I see that container would understand that the class is a listner class by seeing that that class has implemented listener interface. Then, if it doesn't make any difference to specify <listener-class> ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"listener" not "listner". Programming is all about precision and accuracy.

There needs to be some element to declare the class. What's wrong with calling it what it is?
 
jazy smith
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
didn't get you
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • Watch your spelling.
  • Why not call it listener class? What would you call it?
  •  
    Ankit Garg
    Sheriff
    Posts: 9521
    22
    Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The container doesn't check every class in your application if it is a listener class or not. Only listeners declared in the web.xml are registered for listening to events by the container...
     
    Sharad Jadhav
    Greenhorn
    Posts: 18
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    jazy smith wrote:Hi,

    why to write <listener-class> in web.xml ? I see that container would understand that the class is a listener class by seeing that that class has implemented listener interface. Then, if it doesn't make any difference to specify <listener-class> ?


    I am also agree with you. But I also don't know.
     
    James Tharakan
    Ranch Hand
    Posts: 580
    Eclipse IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I think it makes sense in telling the container that these are the listener class because imagine a situation where in a application has hundreds of class and container has to go through each and every class to find out if they are listener implementer or not !!
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic