You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Erik Price <ep...@ptc.com> on 2003/01/03 20:54:14 UTC
servletContext().getInitParameter() not working as expected
Hi,
It seems that when I call getServletContext().getInitParameter(), it
works sometimes but not others. That is to say, I've stored my JDBC
connection URL and the string containing the JDBC driver name in
<context-param> entries. But I've created a "test" <context-param>
entry containing nothing more than a meaningless string. I'm trying to
get this string to echo to output, but it's not happening -- instead,
"null" is getting printed. Anyone have any idea what's up?
Here's the relevant part of my WEB-INF/web.xml:
<context-param>
<param-name>stringtotest</param-name>
<param-value>kasdfasdfadsfl</param-value>
</context-param>
Here's the relevant part of my servlet code:
out.println("<p>And here is the value of our"
+ "<b>stringtotest</b> context parameter: "
+ getServletContext().getInitParameter("stringtotest")
+ "<-- right here");
I get no errors in the logs, or upon restarting the webapp so I know my
WEB-INF/web.xml file is syntactically correct. Also, as I mentioned
above, in the same servlet I'm able to connect to a database using a URL
string from a <context-param> entry. But this context-param entry seems
to only echo "null". Anyone know why?
Thanks,
Erik
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>