I think you want to use getServletContext().getInitParameter("companyName");


There is a difference between a servlet init parameter (defined in web.xml)
and a servlet context init parameter (defined in the context.xml or
server.xml file)

-----Original Message-----
From: Jon Wingfield
To: Tomcat Users List
Sent: 25/03/2004 10:22
Subject: Re: Getting Context Parameters from server.xml

If you had
String name = config.getInitParameter("companyName");
it might work ;)

HTH,

Jon

Michael Jones wrote:
> Hello-
> 
> I'm trying to store some values in my server.xml and then get them
with my 
> Servlet. 
> 
> I followed the instructions at:
> http://jakarta.apache.org/tomcat/tomcat-4.0-doc/config/context.html
> under the "Context Parameters" section.
> 
> In my servlet I got all init params and iterated over the enumeration.
The 
> parameter I defined in server.xml did not show up.
> 
> Has anyone gotten this feature to work? Am I missing something? Here 
> are a few code snippets:
> 
> server.xml in the <Context> tag for my webapp
> <Parameter name="companyName" value="MyCompany" override="false"/>
> 
> from my servlet
> ServletConfig config = getServletConfig();
> String name = getInitParameter("companyName");
> System.err.println("CompanyName = '" + name + "'");
> 
> Enumeration enum = config.getInitParameterNames();
> while(enum.hasMoreElements())
> {
>       System.err.println(enum.nextElement()); 
> }
> 
> 
> Thanks-
> Michael
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to