• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HeadFirst question about Listeners

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys,

I am a Hf rookie and I was trying the mock exam at the end of chap 5 in the HF Servlets & JSP. Check out the question number 6. Pg 217.

I answered C,D thinking that the HttpSessionListener is in the javax.servlet.http package.

But the answer given is B, C & D.

Is there something wrong in my understanding of the question?

Please help. Thanks.

Sue
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't think deeply whether question is about Listeners in a package.
I have some doubts
One of the correct answer is C ServletContextListener can be used to perform an action when servlet context is about to be shutdown.

I am not able to understand this.I know there is a method contextDestroyed(..). I thought this will be called when context is detroyed, not before destroying.Can someone tell me what is correct.
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The contextInitialized method is called when the context is being initialised.
Similarly, the contextDestroyed method is called before the context is actually destroyed!
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think contextInitialized is called after context is initialized and destroyed is called after it is destroyed, which doesn't help much but that's how it goes. Please correct me if i'm wrong.
 
Sue Pillai
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the API.

public void contextInitialized(ServletContextEvent sce)

Notification that the web application initialization process is starting. All ServletContextListeners are notified of context initialization before any filter or servlet in the web application is initialized.

contextDestroyed

public void contextDestroyed(ServletContextEvent sce)

Notification that the servlet context is about to be shut down. All servlets and filters have been destroy()ed before any ServletContextListeners are notified of context destruction.

But guys, the answer to my question??
 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sue,

Yeah.Its a mistake in the HF Book.It should be
Which statements about the listeners are true
instead of
Which statements about the listeners defined in javax.servlet.package are true.
U can find tht at this:


Vineela
 
Sue Pillai
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Vineela, that was a very useful link. I am passing it around in my friends circle.

May be JavaRanch can do that too for the HF users (if they haven't already)
reply
    Bookmark Topic Watch Topic
  • New Topic