This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes getInitParamter(String) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "getInitParamter(String)" Watch "getInitParamter(String)" New topic


andy armstrong
Ranch Hand

Joined: May 14, 2002
Posts: 154
Used in Servlet Config and ServletContext
What is the differences and when should you use which function from which class?

Certifications: <br />scp2, scea, scwcd, WL7.0, CISSP, XML
Mark Howard
Ranch Hand

Joined: Feb 14, 2001
Posts: 285
getInitParameter() in ServletConfig and ServletContext both pertain to initialisation parameters defined in the web.xml deployment descriptor. However, the ServletConfig version is used to retrieve the initialisation parameters of a specific servlet in the web application, and the ServletContext version is to retrieve initialisation parameters that pertain to the entire web application as a whole (eg. database connection stuff).
Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
We usually use getServletConfig().getInitParameter() when we want to get value from web.xml :

And We usually use getServletContext{).getInitParameter() when we want to get value from web.xml :
Correct me if i am wrong...
I agree. Here's the link:
subject: getInitParamter(String)
It's not a secret anymore!