• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Access getInitParamter()

 
Kapil Keskar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Here I want to get the Initialized parameters from 'Server.xml' file in Tomcat Configuration Dir.
I am having problem of how to update the config/server.xml or web-inf/web.xml file on server & by which code. Can any body tell me about this?
Thanking You
 
makiey bartsch
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roughly:
1. Put the init-param into the web.xml:
<servlet>
<servlet-name>...
<servlet-class>...
<init-param>
<param-name>paramName</param-name>
<param-value>paramValue</param-value>
</init-param>
</servlet>
2. Somewhere in your servlet ask for the param-value i.e.:
public void init() throws...
{
String myParamValue =
getServletConfig().getInitParameter("paramName");
// do something with myParamValue...
}
hth,
makiey
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure you give your servlet a registered name. Initialization parameters are not available in servlets that are accessed by their default URL.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic