wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HeadFirst question about Listeners Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HeadFirst question about Listeners" Watch "HeadFirst question about Listeners" New topic
Author

HeadFirst question about Listeners

Sue Pillai
Ranch Hand

Joined: Nov 04, 2004
Posts: 89
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


Sue

SCJP 1.2
SCWCD 1.4
SCBCD 5.0
Sharika Raj
Greenhorn

Joined: Aug 31, 2004
Posts: 26
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.
Kedar Dravid
Ranch Hand

Joined: May 28, 2004
Posts: 333
The contextInitialized method is called when the context is being initialised.
Similarly, the contextDestroyed method is called before the context is actually destroyed!
Bhumika Thakkar
Ranch Hand

Joined: Apr 18, 2005
Posts: 79
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.


SCBCD (Preparing) <br />SCWCD, 82%<br />SCJP, 90%
Sue Pillai
Ranch Hand

Joined: Nov 04, 2004
Posts: 89
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??
Vineela Devi
Ranch Hand

Joined: Dec 20, 2003
Posts: 191
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

Joined: Nov 04, 2004
Posts: 89
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)
 
Consider Paul's rocket mass heater.
 
subject: HeadFirst question about Listeners
 
Similar Threads
HFS page 832 question 63 doubt
Coffee Cream on EB - Mistakes/Doubts #4
HF page 596. Question 2.
Differentiate Custom Tags and JSTL - HF Chapter 9 Mock Exam
Package problem in walkthrough