• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

init and context parameters

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll find init-param in filters too.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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



Yes. Of Course
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I love a good mentalist. And so does this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic