This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Listeners Doubt? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Listeners Doubt?" Watch "Listeners Doubt?" New topic

Listeners Doubt?

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9935


For the example given in the HFSJ book, for the ServletContaxt listener, they have mentioned in the web.xml file as,

<param-value>Great Dane</param-value>

But I feel we don't actually need a listener as I can get the breed just by using getServletContext().getInitParameter("breed");

I guess they have just explained on how to use a ServletContext Listener. Am I right???

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9935

Anyone to help me on my post above?
Meeta Kate

Joined: Mar 06, 2007
Posts: 2
I am newbie to SCWCD preparation, so please correct me if I am wrong.

To me, it looks like the whole puropse of this example is to show how an object can be added in the ServletContext.

From Deployment Decscriptor, you can set only string values.
But if you need to have a object value for a particular parameter, you need to set it via attribute class ( Dog class in the example).

Now as you mentioned, surely you can get the value of breed directly from the context, but what they are trying to demonstrates how Listeners and Attribute class can be used.

SCJP<br />SCWCD- Preparing
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9935

Yes, Thanks for your explanation!
subject: Listeners Doubt?
It's not a secret anymore!