• Post Reply Bookmark Topic Watch Topic
  • New Topic

getInitParameter() ?  RSS feed

 
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 Foreman
Posts: 3991
32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it should be made clear.
thanks for the feedback,
Paul.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!