tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Xia <r...@magnify.com>
Subject RE: Reading initialization parameters from web.xml
Date Tue, 20 Jun 2000 14:15:14 GMT
Try this:
  out.println(getServletContext().getInitParameter(name));

-----Original Message-----
From: Bedell, Kevin [mailto:KBedell@cmgi.com]
Sent: Tuesday, June 20, 2000 8:50 AM
To: 'tomcat-user@jakarta.apache.org'
Subject: Reading initialization parameters from web.xml


I'm having trouble getting parameters read in from my web.xml file. 

I've attached a sample code snippet that tries to read all parameters in and
simply print them out for debugging. The results of the code are that no
paramters are read in or printed.

Also I've attached my web.xml file -

Anyone have any ideas?

Thanks,

Kevin



__________________________________________
Code snippet trying to read init parameters:

    Enumeration enum = getInitParameterNames();
    while (enum.hasMoreElements()) {
      String name = (String) enum.nextElement();
      out.println(name + " : " + getInitParameter(name));
    }

_____________________________
Contents of web.xml file:

<?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>
  <display-name>A Test app for parameter passing</display-name>
  <context-param>
      <param-name>TestParameter</param-name>
      <param-value>This is only a test - parameter!</param-value>
      <description>
         This parameter is here to test the web.xml functionality
      </description>
  </context-param>
  <servlet>
    <servlet-name>Hello</servlet-name>
    <servlet-class>HelloServlet.class</servlet-class>
    <init-param>
    	<param-name>helloName</param-name>
    	<param-value>Kevin</param-value>
    </init-param>
  </servlet>
</web-app>> 

--------------------------------------------------------------------------
To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
For additional commmands, email: tomcat-user-help@jakarta.apache.org

Mime
View raw message