Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

EPractice Lab quiz 3 about listener

 
Bartender
Posts: 1924
13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Which of the events can be monitored by Java EE listeners?
[ Choose three ]

a.when a session is created
b.after a servlet is destroyed
c.when a session has timed out
d.when a cookie has been created
e.when a servlet has forwarded a request
f. when a session attribute value is changed

Choice A, Choice C and Choice F are correct
when a session is created - HttpSessionBindingListener
when a session has timed out - HttpSessionBindingListener
when a session attribute value is changed - HttpSessionAttributeListener
HttpSessionListener is used to receiving notification events about HttpSession lifecycle changes. It Receives notification that a session has been created. Receives notification that a session is about to be invalidated.
HttpSessionBindingListener - Causes an object to be notified when it is bound to or unbound from a session. The object is notified by an HttpSessionBindingEvent object. This may be as a result of a servlet programmer explicitly unbinding an attribute from a session, due to a session being invalidated, or due to a session timing out.
HttpSessionAttributeListener - This listener interface can be implemented in order to get notifications of changes to the attribute lists of sessions within this web application.



I think b is also an option. After a servlet is destroyed, the contextDestroyed method is called.


According to ServletContextListener API:

void contextDestroyed(ServletContextEvent sce)

Receives notification that the ServletContext is about to be shut down.

All servlets and filters will have been destroyed before any ServletContextListeners are notified of context destruction.

Parameters:
sce - the ServletContextEvent containing the ServletContext that is being destroyed


 
Creator of Enthuware JWS+ V6
Posts: 3348
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I think b is also an option. After a servlet is destroyed, the contextDestroyed method is called.


No, you won't get a notification if just one of the Servlets is destroyed.
 
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic