Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

init and context parameters

 
kiranb reddy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can anyone explain the exact difference between <init-param> and <context-param>

What is the main purpose of these parameters.

Please provide me the examples.


Thanks,
Kiran.
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<init-param> is for specific servlet ( where you define those under <servlet> in web.xml) and can be accessed from ServletConfig object. At the time of the initialization of the servlet those are bound to servletConfig. But <context-param> is for the whole application ( where you define those outside <servlet> tag in web.xml) and can be accessed through ServletContext object.
You may refer Servlet FAQ for more information, there you will find lot of information including API & SPEC as well .
[ October 30, 2008: Message edited by: Vijitha Kumara ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll find init-param in filters too.
 
ou yang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<context-param>and<init-param> are used for setting initial parameters.
if you use the first setting,you can get the value of your setting in servlet anywhere.but another hand ,you could only get the value in init method of servlet .
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Christophe Verre
----
You'll find init-param in filters too


Yes. Of Course
 
paramita saha
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
init-param tag is used to specify initial parameters for specific servlets.context-param is also used to specify initial parameters ,but this can be used by different servlets sharing the same context.servlets outside the context can use it but first of all they need to get access to the specific servletContext.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic