File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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)
jQuery in Action, 3rd edition