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]
# 1
So what have you got in the web.xml?
evnafetsa at 2007-7-16 1:31:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

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!

camillea at 2007-7-16 1:31:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
How are you accessing this page?as http://localhost:8080/MyJSP or http://localhost:8080/MyJSP/MyJSP.jsp?I believe they will give two different results.
evnafetsa at 2007-7-16 1:31:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

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!

camillea at 2007-7-16 1:31:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
I just found I still called a wrong file. after I fixed it I got different error:Could not open registry. Registry name: MyJSP.Any suggestions?Thanks again!
camillea at 2007-7-16 1:31:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...