wood burning stoves 2.0*
The moose likes Servlets and the fly likes How to Access getInitParamter() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to Access getInitParamter() " Watch "How to Access getInitParamter() " New topic
Author

How to Access getInitParamter()

Kapil Keskar
Ranch Hand

Joined: Dec 04, 2001
Posts: 47
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

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

Joined: Nov 06, 2000
Posts: 1510
Make sure you give your servlet a registered name. Initialization parameters are not available in servlets that are accessed by their default URL.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Access getInitParamter()
 
Similar Threads
Tomcat doesn't stop
No Context Configured In Server.xml
Error viewing JSP page
Can a website/webapplication run outside Apache Tomcat 5 directory
session.getAttribute give null when retreiving session Data in jsps