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...
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!
Joined: Apr 17, 2002
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: