This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Context-param doubt 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 "Context-param doubt" Watch "Context-param doubt" New topic

Context-param doubt

Srividhya Kiran
Ranch Hand

Joined: Feb 17, 2008
Posts: 166
Which of the following can be used to retrieve the name or value of context param?


Dee Brown
Ranch Hand

Joined: Jun 14, 2008
Posts: 94
Seems like a trick question but I would have to say they all do. This is because all are passed an EventObject (subclass) that has reference to the associated HttpSession object. Through HttpSession.getContext(), the above listeners can call the associated parameter methods to retrieve the names and values of the context parameters.
Srividhya Kiran
Ranch Hand

Joined: Feb 17, 2008
Posts: 166
but the answer given as b & c. Dont know why a & d are wrong.
Dee Brown
Ranch Hand

Joined: Jun 14, 2008
Posts: 94
So it was a trick question.

Your failure to provide that information up front is likely the reason why your question went unanswered for as long as it did. Your failure to provide information on where the question came from leaves little else to go on. The idea here is to make it as easy as possible for others to answer your question. If you also include where the question is from maybe someone else has come across it and has the answer, or knows that the provided answer is in fact wrong (because they reviewed the errata).

However, in this case (assuming they are listed in A-D alphabetical order), I have not identified why A and D would be wrong. Extensive analysis was not performed because it does not appear to be necessary.
Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
From my knowledge below two methoda are available only in HttpSessionAttributeListener and HttpSessionBindingListener which are responsible for accessing the name and value for the param.
1: java.lang.String getName()
2: java.lang.Object getValue()

In HttpSessionActivationListener and HttpSessionListener these methods are not available.
Follow this link:
I agree. Here's the link:
subject: Context-param doubt
Similar Threads
can web.xml data include contents from other xml file
Richfaces skins
NullPointerException in Listener
Spring with Hibernate Integration