You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Marinko, Jeff" <Je...@intuit.com> on 2002/06/26 01:38:37 UTC
Init-Params: Setting and Using
While this should be relatively easy to do....I have no idea why it is not
working...
Misc Notes: Tomcat 4.0.3 running on Win2K (no apache)
For a servlet I am working on, I have the following in my web.xml file for
the webapp:
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>myPackage.MyServlet</servlet-class>
<init-param>
<param-name>DATA_ROOT</param-name>
<param-value>misc data here</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
In my code, I attempt to examine my init-params using the following method:
ServletContext context = conf.getServletContext();
Enumeration enum =
conf.getServletContext().getInitParameterNames();
while (enum.hasMoreElements()) {
String key = (String)enum.nextElement();
System.out.println("Key: " + key + "\tValue: " +
context.getInitParameter(key));
}
I've tried accessing the parameters directly by name as well as enumerating
through them. According to the ServletContext, there are no init
parameters! Is there something special I need to do to "activate" this
feature in Tomcat, or am I missing something obvious (probably the latter)?
Thanks for any feedback!
Jeff
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Init-Params: Setting and Using
Posted by Jacob Hookom <ho...@uwec.edu>.
Try:
String value = getServletConfig().getInitParameter("DATA_ROOT");
Within HttpServlet.init();
-----Original Message-----
From: Marinko, Jeff [mailto:Jeff_Marinko@intuit.com]
Sent: Tuesday, June 25, 2002 6:39 PM
To: 'tomcat-user@jakarta.apache.org'
Subject: Init-Params: Setting and Using
While this should be relatively easy to do....I have no idea why it is
not
working...
Misc Notes: Tomcat 4.0.3 running on Win2K (no apache)
For a servlet I am working on, I have the following in my web.xml file
for
the webapp:
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>myPackage.MyServlet</servlet-class>
<init-param>
<param-name>DATA_ROOT</param-name>
<param-value>misc data here</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
In my code, I attempt to examine my init-params using the following
method:
ServletContext context = conf.getServletContext();
Enumeration enum =
conf.getServletContext().getInitParameterNames();
while (enum.hasMoreElements()) {
String key = (String)enum.nextElement();
System.out.println("Key: " + key + "\tValue: "
+
context.getInitParameter(key));
}
I've tried accessing the parameters directly by name as well as
enumerating
through them. According to the ServletContext, there are no init
parameters! Is there something special I need to do to "activate" this
feature in Tomcat, or am I missing something obvious (probably the
latter)?
Thanks for any feedback!
Jeff
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.371 / Virus Database: 206 - Release Date: 6/13/2002
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.371 / Virus Database: 206 - Release Date: 6/13/2002
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>