ie
<context-param>
<param-name>companyName</param-name>
<param-value>MyCompany</param-value>
</context-param>The original code was looking up the servlet's init parameter, which should be defined:
<servlet>
<servlet-name>param-servlet</servlet-name>
<servlet-class>com.MyCompany.ParamServlet</servlet-class>
<init-param>
<param-name>companyName</param-name>
<param-value>MyCompany</param-value>
</init-param>
</servlet>
These are portable ways (servlet spec compliant) to pass parameters to webapps.
The <Parameter> tags within server.xml are related to Resources (Data Sources etc) and probably not what you want.
Jon
Jon Wingfield wrote:
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]
