Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

getInitParameter() ?

 
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
 
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
 
Enthuware Software Support
Posts: 4428
41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it should be made clear.
thanks for the feedback,
Paul.
 
Our first order of business must be this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic