Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

listener question

 
Sherif Shehab
Ranch Hand
Posts: 487
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have 2 classes named: MyServletContextAttributesListener and MyHttpSessionListener which implement interfaces as suggested by their names.
Which of the following XML fragments, written directly under the <web-app> tag, correctly register these classes so that their instances may receive appropriate notifications?

1.
<listener>
<listener-class>MyServletContextAttributesListener</listener-class>
<listener-class>MyHttpSessionListener</listener-class>
</listener>

2.
<listener-class>MyServletContextAttributesListener</listener-class>
<listener-class>MyHttpSessionListener</listener-class>

3.
<listener>
<listener-class>MyServletContextAttributesListener</listener-class>
</listener>
<listener>
<listener-class>MyHttpSessionListener</listener-class>
</listener>

4.
<context-listener>
<listener-class>MyServletContextAttributesListener</listener-class>
</context-listener>
<session-listener>
<listener-class>MyHttpSessionListener</listener-class>
</session-listener>

5.
<listener>MyServletContextAttributesListener</listener>
<listener>MyHttpSessionListener</listener>

options:
1
2
3
4
5

Answer : 3

Not convinced!!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not convinced!!

Why ? What were you expecting ?
 
Sherif Shehab
Ranch Hand
Posts: 487
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sherif Shehab:
You have 2 classes named: MyServletContextAttributesListener and MyHttpSessionListener which implement interfaces as suggested by their names.
Which of the following XML fragments, written directly under the <web-app> tag, correctly register these classes so that their instances may receive appropriate notifications?

1.
<listener>
<listener-class>MyServletContextAttributesListener</listener-class>
<listener-class>MyHttpSessionListener</listener-class>
</listener>

2.
<listener-class>MyServletContextAttributesListener</listener-class>
<listener-class>MyHttpSessionListener</listener-class>

3.
<listener>
<listener-class>MyServletContextAttributesListener</listener-class>
</listener>
<listener>
<listener-class>MyHttpSessionListener</listener-class>
</listener>

4.
<context-listener>
<listener-class>MyServletContextAttributesListener</listener-class>
</context-listener>
<session-listener>
<listener-class>MyHttpSessionListener</listener-class>
</session-listener>

5.
<listener>MyServletContextAttributesListener</listener>
<listener>MyHttpSessionListener</listener>

options:
1
2
3
4
5

Answer : 3

Not convinced!!


As far as i know that 1 same as 3 , correct me if i'm wrong.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the listener tag accepts only one listener-class subtag. You have to declare a separate listener tag for each listener.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic