• Post Reply Bookmark Topic Watch Topic
  • New Topic

getInitParameter() ?

 
Yu Chen
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question ID :994874119438
Which of the following lines can be inserted at line //1 to retrieve an initialization parameter "dbname" from the init() method of a servlet?
public void init()
{
//1
}
1. getServletConfig().getParameter("dbname");
2. getServletCofig().getInitParameter("dbname");
3. getServletContext().getInitParameter("dbname");
4. getInitParameter("dbname");
5. getParameterValue("dbname");
I would say (2, 3, 4) are all correct.
But the answer is (2, 4)???

Thanks,
-yu chen
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I suppose the question intended servlet init parameters only.
 
Yu Chen
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it makes sense if it asks for the servlet init parameters, but not the context parameters.
Thanks,
-yu chen
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3891
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it should be made clear.
thanks for the feedback,
Paul.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!