getServletConfig().getInitParameter() returns null, pls help!
Hello,
I have a jsp page to call servlet value from web.xml file. My code is
String strParam1 = getServletConfig().getInitParameter("param1");
The jsp pge worked before, but it stop working recently. It always returns "null". I checked web.xml file. It looks well configured.
I also tried to call getServletConfig().getInitParameterNames(), but it returned nothing.
Can somebody tell me what cause this problem and what I should do? Our admin rebooted the server, but it doesn't help.
Thanks for you help in advance!!!
[563 byte] By [
camillea] at [2007-10-2 5:29:27]

This is my web.xml file:
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>MyJSP</servlet-name>
<jsp-file>/JSP/MyJSP.jsp</jsp-file>
<init-param>
<param-name>Param1</param-name>
<param-value>
value1
</param-value>
</init-param>
<init-param>
<param-name>Param2</param-name>
<param-value>
value2
</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>MyJSP</servlet-name>
<url-pattern>/MyJSP</url-pattern>
</servlet-mapping>
</web-app>
MyJSP.jsp file is saved in \\\jakarta-tomcat-4.1.31\webapps\ROOT\WEB-INF
I put this code in MyJsp.jsp:
java.util.Enumeration enum = getServletConfig().getInitParameterNames();
for (; enum.hasMoreElements(); ) {
// Get the name of the init parameter
String name = (String)enum.nextElement();
// Get the value of the init parameter
String value = getServletConfig().getInitParameter(name);
out.println(name + " = " + value);
}
I got
fork = falselogVerbosityLevel = WARNING
Thanks again!
Hey thank you for your help!
When I call http://localhost:8080/MyJSP, it works! I called http://localhost:8080/JSP/MyJSP.jsp before.
Now I have another question. After I move the file to our Dev server which port is 8020, I call
http://computername.corp.com:8020/MyJSP, I got Error 404--Not Found page.
The web.xml file is complicated, but well configured. Any suggestions?
Thanks!