Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

question on context-param

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, guys:
The params defined between <context-param></context-param> are accessible by all servlets. I am wondering how I am able to put
params accessible by all servlets and paran accessible by ony one specific servlet together
in deployment descriptor? Could anyone give an
example? Thanks.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rick,
The DD would look like this.
<web-app>
<context-param>
<param-name> TheParam </param-name>
<param-value> ParamValue </param-value>
</context-param>
<servlet>
<servlet-name> MyServlet </servlet-name>
<servlet-class> ServletOne </servlet-class>
<init-param>
<param-name> MyServletParam </param-name>
<param-value> ValueForMyServlet </param-value>
</init-param>
</servlet>
Regards,
Clark
 
Clark Bruce
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rick,
Be sure to close </web-app> in above example.
Sorry,
Clark
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's correct. Here is another example:
The <context-param> element will provide the ability to make parameters global to a specific web application. While the sub-elemnent <init-param> of the <servlet> element will provide the apility to make parameters available to an individual servlet.
 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, Clark and CJ:
Your examples are very helpful.
 
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic