tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve E. Lee" <js...@csie.nctu.edu.tw>
Subject Tomcat 3.1: config.getInitParameter() solved
Date Thu, 27 Apr 2000 06:27:16 GMT

Hi,

    Below is my configuration with Tomcat 3.1

    Thanks to Jeff Suttor<Jeff.Suttor@Sun.com>, his configuration
    gave us a correct direction to try to solve the problem.


 =========================================

 1. Install Tomcat3.1. Here we use the `test' web-application that comes 
    with Tomcat 3.1, ie, the one that resides in
$TOMCAT_HOME/webapps/test

 2. Don't touch $TOMCAT_HOME/conf/server.xml or
$TOMCAT_HOME/conf/web.xml.

 3. Add this line to $TOMCAT_HOME/conf/tomcat.conf to mount
    test web-application.

    ApJServMount /test /root

 4. Edit $TOMCAT_HOME/webapps/test/WEB-INF/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-name>foo</param-name>
		<param-value>bar</param-value>
	</context-param>
	<servlet>
		<servlet-name>
			jsp
		</servlet-name>
		<servlet-class>
			org.apache.jasper.runtime.JspServlet
		</servlet-class>
		<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>
		<load-on-startup>
			-2147483646 
		</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>
			jsp
		</servlet-name>
		<url-pattern>
			*.jsp
		</url-pattern>
	</servlet-mapping>
</web-app>


 5. $TOMCAT_HOME/webapps/test/jsp/debug.jsp

<%@ page import="java.util.Enumeration" %>

<%
        String arg;
        String val;
        Enumeration enum;

        out.println("<pre>");

		out.println("Servlet name: " + config.getServletName());


        out.println("from application");
		
        enum = application.getInitParameterNames();
        while( enum.hasMoreElements() ) {
            arg = (String)enum.nextElement();
            val = application.getInitParameter(arg);               
            out.println(arg + " = " + val);
        }



        out.println("from config");

        enum = config.getInitParameterNames();
        while( enum.hasMoreElements() ) {
            arg = (String)enum.nextElement();
            val = config.getInitParameter(arg);               
            out.println(arg + " = " + val);
        }


        out.println("</pre>");
%>

  5. start Tomcat by $TOMCAT_HOME/bin/startup.sh
     If everything is ok, you can see these: 

     5-1> $TOMCAT_HOME/logs/tomcat.log:

Context log: path="/test" Adding context path="/test" 
docBase="webapps/test"
Context log: path="/test" Removing duplicate servlet jsp Wrapper(jsp
org.apache.jasper.runtime.JspServlet)
Context log: path="/test" Removing duplicate *.jsp -> Wrapper(jsp
org.apache.jasper.runtime.JspServlet)

     5-2> $TOMCAT_HOME/logs/servlet.log:

Context log path="/test" :tomcat.errorPage: init
Context log path="/test" :default: init
Context log path="/test" :jsp: init

  6. Now you can try http://localhost:port/test/jsp/debug.jsp


  ================================

  Differences between Jeff's web.xml and ours:
  1. JSPServlet --> JspServlet
  2. Add servlet mapping.

-- 
Feel The Power, Experience The Magic.
May the Dark-Force Be With You, Good Luck.

Mime
View raw message