GeeCON Prague 2014*
The moose likes Servlets and the fly likes Is this too obvious and I am blind? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Is this too obvious and I am blind?" Watch "Is this too obvious and I am blind?" New topic
Author

Is this too obvious and I am blind?

Alexandros Adam
Greenhorn

Joined: Apr 17, 2002
Posts: 5
OK, this one is from Natalie Levi's JAVA Web Developer Certification Study Guide:
Which of the following methods is used to retrieve the value associated to the parameter name provided within the init-param tag?
A. getParameter(String name)
B. getInitParameter(String name)
C. getParameters()
D. None of the above

Well, it's the getInitParameter(String name) method of the ServletConfig object that's used to access the servlet-specific param-value(s) defined within the web.xml, isn't it? However, the correct answer answer (as indicated in the book) is A. The exact answer is the following:
A. The getParameter(String name) of the ServletRequest class is used to retrieve the value associated to the name passed in for a specific servlet. This should not be confused with the getInitParameter(String name) method found in the ServletContext class and used to retrieve context parameters.
Well, when I thought the answer was B what I had in mind was the getInitParameter(...) method of the ServletConfig object, not the getInitParameter(...) method of the ServletContext object. So, I'm still confused. Can someone help me please? Thank you guys...
Sri Basavanahally
Ranch Hand

Joined: Oct 07, 2003
Posts: 75
Alexandros, you are right. This seems like a mistake in the book ???
-Sri


UP THE IRONS !
Mark Latham
Greenhorn

Joined: May 27, 2003
Posts: 22
I checked the errata for the book and found this:
2nd paragraph should read:
To retrieve a servlet's initialization parameter defined within the
deployment descriptor, the javax.servlet.GenericServlet class provides
the following method:
getInitParameter(String name)
There are a fair number of errors documented in the errata on the publisher's website. Checking the errata can save yourself a great deal of frustration (a lesson I learned the hard way). It's doubly important when your depending on a book as your certification study guide!
Alexandros Adam
Greenhorn

Joined: Apr 17, 2002
Posts: 5
Now that was really helpful, thank you guys. Too much trust in what's written can seriously harm your chances of success, that's the moral of this story... :roll:
 
GeeCON Prague 2014
 
subject: Is this too obvious and I am blind?