IntelliJ Java IDE
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes question on context-param Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "question on context-param" Watch "question on context-param" New topic
Author

question on context-param

rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
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.
Clark Bruce
Greenhorn

Joined: Feb 27, 2002
Posts: 17
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

Joined: Feb 27, 2002
Posts: 17
Rick,
Be sure to close </web-app> in above example.
Sorry,
Clark
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
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

Joined: Mar 22, 2002
Posts: 208
Thank you very much, Clark and CJ:
Your examples are very helpful.
 
 
subject: question on context-param
 
Threads others viewed
mapping all jsps to single servlets init parameters
ServletConfig & Context ?
Doubt in ServletContextListener
JSP Initialization Parameters
ServletConfig vs ServletContext
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture