• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Intilization parameter

 
Arathi Raj
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic