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 Intilization parameter 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 "Intilization parameter" Watch "Intilization parameter" New topic

Intilization parameter

Arathi Raj
Ranch Hand

Joined: Nov 22, 2002
Posts: 90
what dow we mean by Intilization parameter in servlets. For what it is useful? Why it is defined in deployment descriptor and not in servlet class?
Amit Saini
Ranch Hand

Joined: Oct 20, 2004
Posts: 280
Initialization parameters can be of two types.
a) Context Init Param: This is for the entire application. You can set things like DSN, adminEmail and in general, things which will be used by the entire application ie. all servlets and JSPs within an app can access it.

b) Servlet Init Param: As the name suggests, this is specific to each servlet. Suppose you have two servlets and you want to initialize them with different properties, servlet init params are useful.

You can also set them in the servlet class but anytime you want to change them, you have to recompile your java files and redeploy the application. If you set them in web.xml, its easier to change and no compilation is needed. Remember that these values are initialized only once. After deployment, if you change the web.xml init params, this change won't be visible unless you restart the app server or redeploy the app.

Hope that helps
I agree. Here's the link:
subject: Intilization parameter
It's not a secret anymore!