wood burning stoves 2.0*
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
Author

getInitParamter(String)

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
Andy
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).
Mark.
Fisher Daniel
Ranch Hand

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

<web-app>
.....
<servlet>
....
<init-param>
<param-name>Param1</param-name>
<param-value>ValueOfParam1</param-value>
</init-param>
</servlet>
....
</web-app>
And We usually use getServletContext{).getInitParameter() when we want to get value from web.xml :
<web-app>
.....
<context-param>
<param-name>Param1</param-name>
<param-value>ValueOfParam1</param-value>
</context-param>
Correct me if i am wrong...
daniel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getInitParamter(String)