I guess that your having a wrong JSDK in your classpath.
ServletContext.getInitParameter() has been introduced with JSDK 2.2.
Versions prior to this just had GenricServlet.getInitParmeter()
and ServletConfig..getInitParmeter().
-Ursprüngliche Nachricht-
Von: Marcel van Beurden (ETM)
[mailto:[EMAIL PROTECTED]]
Gesendet: Dienstag, 24. April 2001 09:21
An: '[EMAIL PROTECTED]'
Betreff: Getting context-param in servlet problems...ARGH
Hi there,
I'm going slightly crazy. I want to get a parameter from the
context-param section from my web.xml in my servlet. But I
can't get it to work.
I quote from the example web.xml in the Tomcat docs:
quote
The values actually assigned to these parameters can be
retrieved in a servlet or JSP page by calling:
String value = getServletContext().getInitParameter(name);
where name matches the param-name element of one of
these initialization parameters.
/quote
When I copy and paste this line of code into my init() method
of my servlet I get a compilation error:
MyServlet.java: Error #: 300 : method
getInitParameter(java.lang.String) not found in interface
javax.servlet.ServletContext at line 35, column 40
I'm really confused now. My web.xml is below. Help !
Best regards,
Marcel
My web.xml:
?xml version=1.0 encoding=ISO-8859-1?
!DOCTYPE web-app
PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.2//EN
http://java.sun.com/j2ee/dtds/web-app_2_2.dtd;
web-app
context-param
param-namejdbcDriverName/param-name
param-valueorg.gjt.mm.mysql.Driver/param-value
/context-param
context-param
param-namejdbcConnectString/param-name
param-valuejdbc:mysql://localhost/db/param-value
/context-param
servlet
servlet-name
servlet1
/servlet-name
servlet-class
Servlet1
/servlet-class
/servlet
servlet
servlet-name
servlet2
/servlet-name
servlet-class
Servlet2
/servlet-class
/servlet
servlet-mapping
servlet-nameservlet1/servlet-name
url-pattern/*/url-pattern
/servlet-mapping
servlet-mapping
servlet-nameservlet2/servlet-name
url-pattern/log/*/url-pattern
/servlet-mapping
/web-app