This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getInitParameter(...) major confusion

 
Alexandros Adam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 (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...
 
Sathya Sankar
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right. Book is wrong. Ans is B - ServletConfig.getInitParameter(String)
-GSS
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, your answer is correct... It should be B. Every initial parameter are fetched by using getInitParameter(String) method... I am sure that A is wrong....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic