tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/valves AccessLogValve.java
Date Sat, 29 Apr 2000 05:59:57 GMT
craigmcc    00/04/28 22:59:57

  Modified:    proposals/catalina build.xml
               proposals/catalina/src/conf server.xml
               proposals/catalina/src/share/org/apache/tomcat Host.java
               proposals/catalina/src/share/org/apache/tomcat/connector
                        ResponseBase.java
               proposals/catalina/src/share/org/apache/tomcat/core
                        ContainerBase.java LocalStrings.properties
                        StandardContext.java StandardEngine.java
                        StandardHost.java StandardWrapper.java
                        StandardWrapperValve.java
               proposals/catalina/src/share/org/apache/tomcat/loader
                        StandardLoader.java
               proposals/catalina/src/share/org/apache/tomcat/resources
                        StandardResources.java
               proposals/catalina/src/share/org/apache/tomcat/startup
                        Catalina.java ContextConfig.java
                        LocalStrings.properties
               proposals/catalina/src/share/org/apache/tomcat/valves
                        AccessLogValve.java
  Added:       proposals/catalina/src/conf tomcat-users.xml web.xml
               proposals/catalina/src/share/org/apache/tomcat/servlets
                        DefaultServlet.java
  Log:
  Debug to the point where Catalina can serve it's first static files.  Lots
  of debugging on the default servlet is still needed, including:
  - Correct processing of If-Modified-Since
  - Welcome files when processing a directory
  - URL-based resource rendering (including last-modified check?)
  - Deal with URLs like "http://localhost:8080" and "http://localhost:8080/"
  - Tuning to discover the optimum default buffer sizes
  
  Revision  Changes    Path
  1.9       +0 -4      jakarta-tomcat/proposals/catalina/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/build.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- build.xml	2000/04/27 05:55:12	1.8
  +++ build.xml	2000/04/29 05:59:51	1.9
  @@ -42,10 +42,6 @@
   
     <!-- Clean and recopy the web applications from Tomcat -->
     <target name="webapps">
  -    <copyfile src="${tomcat.build}/conf/web.xml"
  -             dest="${catalina.build}/conf/web.xml"/>
  -    <copyfile src="${tomcat.build}/conf/tomcat-users.xml"
  -             dest="${catalina.build}/conf/tomcat-users.xml"/>
       <deltree dir="${catalina.build}/webapps"/>
       <mkdir   dir="${catalina.build}/webapps"/>
       <copydir src="${tomcat.build}/webapps" dest="${catalina.build}/webapps"/>
  
  
  
  1.10      +14 -8     jakarta-tomcat/proposals/catalina/src/conf/server.xml
  
  Index: server.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/conf/server.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- server.xml	2000/04/27 05:55:13	1.9
  +++ server.xml	2000/04/29 05:59:51	1.10
  @@ -2,7 +2,7 @@
   <!-- Note that component elements are nested corresponding to their
        parent-child relationships with each other -->
   
  -<Server port="8005" shutdown="SHUTDOWN">
  +<Server port="8005" shutdown="SHUTDOWN" debug="0">
   
     <!-- Define all the connectors to associate with the following container -->
   
  @@ -12,7 +12,7 @@
   
     <!-- Define the top level container in our container hierarchy -->
   
  -  <Engine name="engine" defaultHost="localhost" unknownHost="localhost">
  +  <Engine name="engine" defaultHost="localhost" debug="0">
   
       <!-- Global logger unless overridden at lower levels -->
       <Logger className="org.apache.tomcat.logger.FileLogger"
  @@ -20,10 +20,14 @@
               timestamp="true"/>
   
       <!-- Because this Realm is here, an instance will be shared globally -->
  -    <Realm className="org.apache.tomcat.realm.MemoryRealm" debug="2"/>
  +    <Realm className="org.apache.tomcat.realm.MemoryRealm"/>
   
  -    <Host name="localhost">
  +    <Host name="localhost" debug="0">
   
  +      <!-- Add aliases (these are specific to my setup!) -->
  +      <Alias>neptune</Alias>
  +      <Alias>neptune.mcclan.net</Alias>
  +
         <!-- Access log processes all requests for this virtual host -->
         <Valve className="org.apache.tomcat.valves.AccessLogValve"
                directory="logs" prefix="localhost_access_log." suffix=""
  @@ -35,16 +39,18 @@
                 timestamp="true"/>
   
         <!-- Root Context -->
  -      <Context path="/" docBase="webapps/ROOT">
  -        <Listener className="org.apache.tomcat.startup.ContextConfig"/>
  +      <Context path="" docBase="webapps/ROOT" debug="0">
  +        <Listener className="org.apache.tomcat.startup.ContextConfig"
  +	          debug="0"/>
           <Manager className="org.apache.tomcat.session.StandardManager"
   	         checkInterval="15" maxActiveSessions="100"
   		 pathname="sessions/localhost_ROOT.sessions"/>
         </Context>
   
         <!-- Examples Context -->
  -      <Context path="/examples" docBase="webapps/examples">
  -        <Listener className="org.apache.tomcat.startup.ContextConfig"/>
  +      <Context path="/examples" docBase="webapps/examples" debug="0">
  +        <Listener className="org.apache.tomcat.startup.ContextConfig"
  +	          debug="0"/>
           <Manager className="org.apache.tomcat.session.StandardManager"
   	         checkInterval="15" maxActiveSessions="100"
                    pathname="sessions/localhost_examples.sessions"/>
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/conf/tomcat-users.xml
  
  Index: tomcat-users.xml
  ===================================================================
  <tomcat-users>
    <user name="tomcat" password="tomcat" roles="tomcat" />
    <user name="role1"  password="tomcat" roles="role1"  />
    <user name="both"   password="tomcat" roles="tomcat,role1" />
  </tomcat-users>
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/conf/web.xml
  
  Index: 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>
  
    <!-- The default servlet that normally serves static resources -->
    <servlet>
      <servlet-name>default</servlet-name>
      <servlet-class>org.apache.tomcat.servlets.DefaultServlet</servlet-class>
      <load-on-startup>-2147483646</load-on-startup>
      <init-param>
        <param-name>debug</param-name>
        <param-value>99</param-value>
      </init-param>
    </servlet>
  
    <!-- The invoker servlet that executes non-registered servlets -->
    <servlet>
      <servlet-name>invoker</servlet-name>
      <servlet-class>org.apache.tomcat.servlets.InvokerServlet</servlet-class>
      <init-param>
        <param-name>debug</param-name>
        <param-value>99</param-value>
      </init-param>
    </servlet>
  
    <!-- The JSP page compiler and execution servlet -->
    <servlet>
      <servlet-name>jsp</servlet-name>
      <servlet-class>org.apache.jasper.runtime.JspServlet</servlet-class>
      <!-- Uncomment the following to use Jikes for JSP compilation -->
  <!--
      <init-param>
        <param-name>jspCompilerPlugin</param-name>
        <param-value>org.apache.jasper.compiler.JikesJavaCompiler</param-value>
      </init-param>
  -->
  <!--
      <load-on-startup>-2147483646</load-on-startup>
  -->
    </servlet>
  
    <!-- The mapping for the default servlet -->
    <servlet-mapping>
      <servlet-name>default</servlet-name>
      <url-pattern>/</url-pattern>
    </servlet-mapping>
  
    <!-- The mapping for the invoker servlet -->
    <servlet-mapping>
      <servlet-name>invoker</servlet-name>
      <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
  
    <!-- The mapping for the JSP servlet -->
    <servlet-mapping>
      <servlet-name>jsp</servlet-name>
      <url-pattern>*.jsp</url-pattern>
    </servlet-mapping>
  
    <!-- Set the default session timeout (in seconds) -->
    <session-config>
      <session-timeout>30</session-timeout>
    </session-config>
  
    <!-- Establish the default MIME type mappings -->
    <mime-mapping>
      <extension>txt</extension>
      <mime-type>text/plain</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>html</extension>
      <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>htm</extension>
      <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>gif</extension>
      <mime-type>image/gif</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>jpg</extension>
      <mime-type>image/jpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>jpe</extension>
      <mime-type>image/jpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>jpeg</extension>
      <mime-type>image/jpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>java</extension>
      <mime-type>text/plain</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>body</extension>
      <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>rtx</extension>
      <mime-type>text/richtext</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>tsv</extension>
      <mime-type>text/tab-separated-values</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>etx</extension>
      <mime-type>text/x-setext</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>ps</extension>
      <mime-type>application/x-postscript</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>class</extension>
      <mime-type>application/java</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>csh</extension>
      <mime-type>application/x-csh</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>sh</extension>
      <mime-type>application/x-sh</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>tcl</extension>
      <mime-type>application/x-tcl</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>tex</extension>
      <mime-type>application/x-tex</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>texinfo</extension>
      <mime-type>application/x-texinfo</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>texi</extension>
      <mime-type>application/x-texinfo</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>t</extension>
      <mime-type>application/x-troff</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>tr</extension>
      <mime-type>application/x-troff</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>roff</extension>
      <mime-type>application/x-troff</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>man</extension>
      <mime-type>application/x-troff-man</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>me</extension>
      <mime-type>application/x-troff-me</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>ms</extension>
      <mime-type>application/x-wais-source</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>src</extension>
      <mime-type>application/x-wais-source</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>zip</extension>
      <mime-type>application/zip</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>bcpio</extension>
      <mime-type>application/x-bcpio</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>cpio</extension>
      <mime-type>application/x-cpio</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>gtar</extension>
      <mime-type>application/x-gtar</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>shar</extension>
      <mime-type>application/x-shar</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>sv4cpio</extension>
      <mime-type>application/x-sv4cpio</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>sv4crc</extension>
      <mime-type>application/x-sv4crc</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>tar</extension>
      <mime-type>application/x-tar</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>ustar</extension>
      <mime-type>application/x-ustar</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>dvi</extension>
      <mime-type>application/x-dvi</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>hdf</extension>
      <mime-type>application/x-hdf</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>latex</extension>
      <mime-type>application/x-latex</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>bin</extension>
      <mime-type>application/octet-stream</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>oda</extension>
      <mime-type>application/oda</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>pdf</extension>
      <mime-type>application/pdf</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>ps</extension>
      <mime-type>application/postscript</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>eps</extension>
      <mime-type>application/postscript</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>ai</extension>
      <mime-type>application/postscript</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>rtf</extension>
      <mime-type>application/rtf</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>nc</extension>
      <mime-type>application/x-netcdf</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>cdf</extension>
      <mime-type>application/x-netcdf</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>cer</extension>
      <mime-type>application/x-x509-ca-cert</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>exe</extension>
      <mime-type>application/octet-stream</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>gz</extension>
      <mime-type>application/x-gzip</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>Z</extension>
      <mime-type>application/x-compress</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>z</extension>
      <mime-type>application/x-compress</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>hqx</extension>
      <mime-type>application/mac-binhex40</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>mif</extension>
      <mime-type>application/x-mif</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>ief</extension>
      <mime-type>image/ief</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>tiff</extension>
      <mime-type>image/tiff</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>tif</extension>
      <mime-type>image/tiff</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>ras</extension>
      <mime-type>image/x-cmu-raster</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>pnm</extension>
      <mime-type>image/x-portable-anymap</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>pbm</extension>
      <mime-type>image/x-portable-bitmap</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>pgm</extension>
      <mime-type>image/x-portable-graymap</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>ppm</extension>
      <mime-type>image/x-portable-pixmap</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>rgb</extension>
      <mime-type>image/x-rgb</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>xbm</extension>
      <mime-type>image/x-xbitmap</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>xpm</extension>
      <mime-type>image/x-xpixmap</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>xwd</extension>
      <mime-type>image/x-xwindowdump</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>au</extension>
      <mime-type>audio/basic</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>snd</extension>
      <mime-type>audio/basic</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>aif</extension>
      <mime-type>audio/x-aiff</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>aiff</extension>
      <mime-type>audio/x-aiff</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>aifc</extension>
      <mime-type>audio/x-aiff</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>wav</extension>
      <mime-type>audio/x-wav</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>mpeg</extension>
      <mime-type>video/mpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>mpg</extension>
      <mime-type>video/mpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>mpe</extension>
      <mime-type>video/mpeg</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>qt</extension>
      <mime-type>video/quicktime</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>mov</extension>
      <mime-type>video/quicktime</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>avi</extension>
      <mime-type>video/x-msvideo</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>movie</extension>
      <mime-type>video/x-sgi-movie</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>avx</extension>
      <mime-type>video/x-rad-screenplay</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>wrl</extension>
      <mime-type>x-world/x-vrml</mime-type>
    </mime-mapping>
    <mime-mapping>
      <extension>mpv2</extension>
      <mime-type>video/mpeg2</mime-type>
    </mime-mapping>
  
    <!-- Establish the default list of welcome files -->
    <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
    </welcome-file-list>
  
  </web-app>
  
  
  
  1.3       +44 -4     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Host.java
  
  Index: Host.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Host.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Host.java	2000/04/23 01:42:28	1.2
  +++ Host.java	2000/04/29 05:59:53	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Host.java,v 1.2 2000/04/23 01:42:28 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/04/23 01:42:28 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Host.java,v 1.3 2000/04/29 05:59:53 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/04/29 05:59:53 $
    *
    * ====================================================================
    *
  @@ -91,12 +91,29 @@
    * an individual servlet context), depending upon the Engine implementation.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/04/23 01:42:28 $
  + * @version $Revision: 1.3 $ $Date: 2000/04/29 05:59:53 $
    */
   
   public interface Host extends Container {
   
   
  +    // ----------------------------------------------------- Manifest Constants
  +
  +
  +    /**
  +     * The ContainerEvent event type sent when a new alias is added
  +     * by <code>addAlias()</code>.
  +     */
  +    public static final String ADD_ALIAS_EVENT = "addAlias";
  +
  +
  +    /**
  +     * The ContainerEvent event type sent when an old alias is removed
  +     * by <code>removeAlias()</code>.
  +     */
  +    public static final String REMOVE_ALIAS_EVENT = "removeAlias";
  +
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -132,6 +149,21 @@
   
   
       /**
  +     * Add an alias name that should be mapped to this same Host.
  +     *
  +     * @param alias The alias to be added
  +     */
  +    public void addAlias(String alias);
  +
  +
  +    /**
  +     * Return the set of alias names for this Host.  If none are defined,
  +     * a zero length array is returned.
  +     */
  +    public String[] findAliases();
  +
  +
  +    /**
        * Return the Context that should be used to process this request,
        * based on matching the longest possible context path (or selecting
        * the default context).  If no such Context can be identified,
  @@ -150,6 +182,14 @@
        * @param uri Request URI to be mapped
        */
       public Context map(String uri);
  +
  +
  +    /**
  +     * Remove the specified alias name from the aliases for this Host.
  +     *
  +     * @param alias Alias name to be removed
  +     */
  +    public void removeAlias(String alias);
   
   
   }
  
  
  
  1.6       +5 -5      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java
  
  Index: ResponseBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ResponseBase.java	2000/04/18 03:45:15	1.5
  +++ ResponseBase.java	2000/04/29 05:59:53	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java,v 1.5 2000/04/18 03:45:15 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/04/18 03:45:15 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/ResponseBase.java,v 1.6 2000/04/29 05:59:53 craigmcc Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/04/29 05:59:53 $
    *
    * ====================================================================
    *
  @@ -87,7 +87,7 @@
    * the connector-specific methods need to be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.5 $ $Date: 2000/04/18 03:45:15 $
  + * @version $Revision: 1.6 $ $Date: 2000/04/29 05:59:53 $
    */
   
   public abstract class ResponseBase
  @@ -437,7 +437,7 @@
   	    throw new IllegalStateException
   		(sm.getString("responseBase.getOutputStream.ise"));
   
  -	if (stream != null)
  +	if (stream == null)
   	    stream = createOutputStream();
   	return (stream);
   
  
  
  
  1.14      +84 -44    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java
  
  Index: ContainerBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ContainerBase.java	2000/04/27 05:55:15	1.13
  +++ ContainerBase.java	2000/04/29 05:59:53	1.14
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java,v 1.13 2000/04/27 05:55:15 craigmcc Exp $
  - * $Revision: 1.13 $
  - * $Date: 2000/04/27 05:55:15 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java,v 1.14 2000/04/29 05:59:53 craigmcc Exp $
  + * $Revision: 1.14 $
  + * $Date: 2000/04/29 05:59:53 $
    *
    * ====================================================================
    *
  @@ -149,7 +149,7 @@
    * class comments of the implementation class.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.13 $ $Date: 2000/04/27 05:55:15 $
  + * @version $Revision: 1.14 $ $Date: 2000/04/29 05:59:53 $
    */
   
   public abstract class ContainerBase
  @@ -172,6 +172,12 @@
   
   
       /**
  +     * The debugging detail level for this component.
  +     */
  +    protected int debug = 0;
  +
  +
  +    /**
        * The first Valve in the pipeline associated with this Container.
        */
       protected Valve first = null;
  @@ -272,12 +278,19 @@
        */
       public synchronized void setBasic(Valve valve) {
   
  -	// Are we actually changing components?
  +	// Change components if necessary
   	Valve oldBasic = this.basic;
   	if (oldBasic == valve)
   	    return;
  +	this.basic = valve;
   
  -	// Stop the old component if necessary
  +	// Stop the old component if necessary and remove it from the pipeline
  +	if (oldBasic != null) {
  +	    Valve previous = getLast();
  +	    if (previous != null)
  +		previous.setNext(null);
  +	    oldBasic.setContainer(null);
  +	}
   	if (started && (oldBasic != null) && (oldBasic instanceof Lifecycle)) {
   	    try {
   		((Lifecycle) oldBasic).stop();
  @@ -286,10 +299,10 @@
   	    }
   	}
   
  -	// Start the new component if necessary
  -	if (valve != null) {
  -	    valve.setContainer((Container) this);
  -	    valve.setNext(null);
  +	// Start the new component if necessary and link it into the pipeline
  +	if (this.basic != null) {
  +	    this.basic.setContainer((Container) this);
  +	    this.basic.setNext(null);
   	}
   	if (started && (valve != null) && (valve instanceof Lifecycle)) {
   	    try {
  @@ -298,22 +311,10 @@
   		log("ContainerBase.setBasic: start: ", e);
   	    }
   	}
  -
  -	// Link the new component into the pipeline
  -	if (basic == null) {
  +	if (this.basic != null) {
   	    Valve previous = getLast();
   	    if (previous != null)
  -		previous.setNext(valve);
  -	    valve.setPrevious(previous);
  -	} else {
  -	    Valve previous = basic.getPrevious();
  -	    if (previous != null)
  -		previous.setNext(valve);
  -	    valve.setPrevious(previous);
  -	    basic.setContainer(null);
  -	    basic.setNext(null);
  -	    basic.setPrevious(null);
  -	    basic = valve;
  +		previous.setNext(this.basic);
   	}
   
   	// Report this property change to interested listeners
  @@ -323,6 +324,31 @@
   
   
       /**
  +     * Return the debugging detail level for this component.
  +     */
  +    public int getDebug() {
  +
  +	return (this.debug);
  +
  +    }
  +
  +
  +    /**
  +     * Set the debugging detail level for this component.
  +     *
  +     * @param debug The new debugging detail level
  +     */
  +    public void setDebug(int debug) {
  +
  +	int oldDebug = this.debug;
  +	this.debug = debug;
  +	support.firePropertyChange("debug", new Integer(oldDebug),
  +				   new Integer(this.debug));
  +
  +    }
  +
  +
  +    /**
        * Return descriptive information about this Container implementation and
        * the corresponding version number, in the format
        * <code>&lt;description&gt;/&lt;version&gt;</code>.
  @@ -370,10 +396,11 @@
        */
       public synchronized void setLoader(Loader loader) {
   
  -	// Are we actually changing components?
  +	// Change components if necessary
   	Loader oldLoader = this.loader;
   	if (oldLoader == loader)
   	    return;
  +	this.loader = loader;
   
   	// Stop the old component if necessary
   	if (started && (oldLoader != null) &&
  @@ -397,8 +424,7 @@
   	    }
   	}
   
  -	// Perform the property change and report it
  -	this.loader = loader;
  +	// Report this property change to interested listeners
   	support.firePropertyChange("loader", oldLoader, this.loader);
   
       }
  @@ -427,10 +453,11 @@
        */
       public synchronized void setLogger(Logger logger) {
   
  -	// Are we actually changing components?
  +	// Change components if necessary
   	Logger oldLogger = this.logger;
   	if (oldLogger == logger)
   	    return;
  +	this.logger = logger;
   
   	// Stop the old component if necessary
   	if (started && (oldLogger != null) &&
  @@ -454,8 +481,7 @@
   	    }
   	}
   
  -	// Perform the property change and report it
  -	this.logger = logger;
  +	// Report this property change to interested listeners
   	support.firePropertyChange("logger", oldLogger, this.logger);
   
       }
  @@ -484,10 +510,11 @@
        */
       public synchronized void setManager(Manager manager) {
   
  -	// Are we actually changing components?
  +	// Change components if necessary
   	Manager oldManager = this.manager;
   	if (oldManager == manager)
   	    return;
  +	this.manager = manager;
   
   	// Stop the old component if necessary
   	if (started && (oldManager != null) &&
  @@ -511,8 +538,7 @@
   	    }
   	}
   
  -	// Perform the property change and report it
  -	this.manager = manager;
  +	// Report this property change to interested listeners
   	support.firePropertyChange("manager", oldManager, this.manager);
   
       }
  @@ -575,7 +601,7 @@
       public void setParent(Container container) {
   
   	Container oldParent = this.parent;
  -	this.parent = parent;
  +	this.parent = container;
   	support.firePropertyChange("parent", oldParent, this.parent);
   
       }
  @@ -604,10 +630,11 @@
        */
       public synchronized void setRealm(Realm realm) {
   
  -	// Are we actually changing components?
  +	// Change components if necessary
   	Realm oldRealm = this.realm;
   	if (oldRealm == realm)
   	    return;
  +	this.realm = realm;
   
   	// Stop the old component if necessary
   	if (started && (oldRealm != null) &&
  @@ -631,8 +658,7 @@
   	    }
   	}
   
  -	// Perform the property change and report it
  -	this.realm = realm;
  +	// Report this property change to interested listeners
   	support.firePropertyChange("realm", oldRealm, this.realm);
   
       }
  @@ -661,10 +687,11 @@
        */
       public synchronized void setResources(Resources resources) {
   
  -	// Are we actually changing components?
  +	// Change components if necessary
   	Resources oldResources = this.resources;
   	if (oldResources == resources)
   	    return;
  +	this.resources = resources;
   
   	// Stop the old component if necessary
   	if (started && (oldResources != null) &&
  @@ -690,8 +717,7 @@
   	    }
   	}
   
  -	// Perform the property change and report it
  -	this.resources = resources;
  +	// Report this property change to interested listeners
   	support.firePropertyChange("resources", oldResources, this.resources);
   
       }
  @@ -1142,9 +1168,9 @@
   
   	Logger logger = getLogger();
   	if (logger != null)
  -	    logger.log(message);
  +	    logger.log(logName() + ": " + message);
   	else
  -	    System.out.println(message);
  +	    System.out.println(logName() + ": " + message);
   
       }
   
  @@ -1160,11 +1186,25 @@
   
   	Logger logger = getLogger();
   	if (logger != null)
  -	    logger.log(message, throwable);
  +	    logger.log(logName() + ": " + message, throwable);
   	else {
  -	    System.out.println(message + ": " + throwable);
  +	    System.out.println(logName() + ": " + message + ": " + throwable);
   	    throwable.printStackTrace(System.out);
   	}
  +
  +    }
  +
  +
  +    /**
  +     * Return the abbreviated name of this container for logging messsages
  +     */
  +    protected String logName() {
  +
  +	String className = this.getClass().getName();
  +	int period = className.lastIndexOf(".");
  +	if (period >= 0)
  +	    className = className.substring(period + 1);
  +	return (className + "[" + getName() + "]");
   
       }
   
  
  
  
  1.10      +6 -0      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/LocalStrings.properties,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- LocalStrings.properties	2000/04/26 02:14:50	1.9
  +++ LocalStrings.properties	2000/04/29 05:59:53	1.10
  @@ -1,17 +1,21 @@
   containerBase.alreadyStarted=Container has already been started
  +containerBase.notConfigured=No basic Valve has been configured
   containerBase.notStarted=Container has not been started
   interceptorValve.alreadyStarted=InterceptorValve has already been started
   interceptorValve.notStarted=InterceptorValve has not yet been started
   standardContext.alreadyStarted=Context has already been started
  +standardContext.mappingError=MAPPING configuration error for relative URI {0}
   standardContext.notStarted=Context has not yet been started
   standardContext.notWrapper=Child of a Context must be a Wrapper
   standardEngine.alreadyStarted=Engine has already been started
  +standardEngine.mappingError=MAPPING configuration error for server name {0}
   standardEngine.notHost=Child of an Engine must be a Host
   standardEngine.notParent=Engine cannot have a parent Container
   standardEngine.notStarted=Engine has not yet been started
   standardEngine.unfoundHost=Virtual host {0} not found
   standardEngine.unknownHost=No server host specified in this request
   standardHost.alreadyStarted=Host has already been started
  +standardHost.mappingError=MAPPING configuration error for requset URI {0}
   standardHost.noContext=No Context configured to process this request
   standardHost.noHost=No Host configured to process this request
   standardHost.notContext=Child of a Host must be a Context
  @@ -22,6 +26,8 @@
   standardServer.start.connectors=At least one connector is not associated with any container
   standardServer.start.started=This server has already been started
   standardServer.stop.notStarted=This server has not yet been started
  +standardWrapper.loadError=Exception loading servlet of class {0}
   standardWrapper.noChild=Wrapper cannot have a child Container
   standardWrapper.noLoader=Wrapper cannot find the Loader to use
   standardWrapper.noServlet=No servlet class has been configured
  +standardWrapper.servletException=Servlet execution threw exception
  
  
  
  1.12      +51 -11    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StandardContext.java	2000/04/26 02:14:50	1.11
  +++ StandardContext.java	2000/04/29 05:59:53	1.12
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v 1.11 2000/04/26 02:14:50 craigmcc Exp $
  - * $Revision: 1.11 $
  - * $Date: 2000/04/26 02:14:50 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v 1.12 2000/04/29 05:59:53 craigmcc Exp $
  + * $Revision: 1.12 $
  + * $Date: 2000/04/29 05:59:53 $
    *
    * ====================================================================
    *
  @@ -92,7 +92,7 @@
    * requests directed to a particular servlet.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.11 $ $Date: 2000/04/26 02:14:50 $
  + * @version $Revision: 1.12 $ $Date: 2000/04/29 05:59:53 $
    */
   
   public final class StandardContext
  @@ -232,9 +232,9 @@
   
   
       /**
  -     * The welcome files for this application, keyed by welcome file name.
  +     * The welcome files for this application
        */
  -    private Hashtable welcomeFiles = new Hashtable();
  +    private Vector welcomeFiles = new Vector();
   
   
       /**
  @@ -654,7 +654,8 @@
        */
       public void addWelcomeFile(String name) {
   
  -	welcomeFiles.put(name, name);
  +	welcomeFiles.addElement(name);
  +	postWelcomeFiles();
   	fireContainerEvent("addWelcomeFile", name);
   
       }
  @@ -1023,7 +1024,13 @@
        */
       public boolean findWelcomeFile(String name) {
   
  -	return (welcomeFiles.get(name) != null);
  +	synchronized (welcomeFiles) {
  +	    for (int i = 0; i < welcomeFiles.size(); i++) {
  +		if (name.equals((String) welcomeFiles.elementAt(i)))
  +		    return (true);
  +	    }
  +	    return (false);
  +	}
   
       }
   
  @@ -1036,9 +1043,8 @@
   
   	synchronized (welcomeFiles) {
   	    String results[] = new String[welcomeFiles.size()];
  -	    Enumeration elements = welcomeFiles.keys();
   	    for (int i = 0; i < results.length; i++)
  -		results[i] = (String) elements.nextElement();
  +		results[i] = (String) welcomeFiles.elementAt(i);
   	    return (results);
   	}
   
  @@ -1077,6 +1083,8 @@
   	String requestURI =
   	    ((HttpServletRequest) request.getRequest()).getRequestURI();
   	String relativeURI = requestURI.substring(contextPath.length());
  +	if (debug > 0)
  +	    log("Mapping relative URI '" + relativeURI + "'");
   
   	// Apply the standard request URI mapping rules from the specification
   	Wrapper wrapper = null;
  @@ -1086,6 +1094,8 @@
   
   	// Rule 1 -- Exact Match
   	if (wrapper == null) {
  +	    if (debug > 1)
  +		log("  Trying exact match");
   	    name = (String) servletMappings.get(relativeURI);
   	    if (name != null)
   		wrapper = (Wrapper) findChild(name);
  @@ -1097,6 +1107,8 @@
   
   	// Rule 2 -- Prefix Match
   	if (wrapper == null) {
  +	    if (debug > 1)
  +		log("  Trying prefix match");
   	    servletPath = relativeURI;
   	    while (true) {
   		int slash = servletPath.lastIndexOf("/");
  @@ -1118,6 +1130,8 @@
   
   	// Rule 3 -- Extension Match
   	if (wrapper == null) {
  +	    if (debug > 1)
  +		log("  Trying extension match");
   	    int slash = relativeURI.lastIndexOf("/");
   	    if (slash >= 0) {
   		String last = relativeURI.substring(slash);
  @@ -1137,6 +1151,8 @@
   
   	// Rule 4 -- Default Match
   	if (wrapper == null) {
  +	    if (debug > 1)
  +		log("  Trying default match");
   	    name = (String) servletMappings.get("/");
   	    if (name != null)
   		wrapper = (Wrapper) findChild(name);
  @@ -1147,7 +1163,18 @@
   	}
   
   
  +	// Complain if there is no match at all
  +	if (wrapper == null) {
  +	    log(sm.getString("standardContext.mappingError", relativeURI));
  +	    return (null);
  +	}
  +	
  +
   	// Update the Request (if requested) and return this Wrapper
  +	if (debug > 0)
  +	    log(" Mapped to servlet '" + wrapper.getName() +
  +		"' with servlet path '" + servletPath +
  +		"' and path info '" + pathInfo + "' and update=" + update);
   	if (update) {
   	    request.setWrapper(wrapper);
   	    ((HttpRequest) request).setServletPath(servletPath);
  @@ -1159,6 +1186,18 @@
   
   
       /**
  +     * Post a copy of our current list of welcome files as a servlet context
  +     * attribute, so that the default servlet can find them.
  +     */
  +    private void postWelcomeFiles() {
  +
  +	getServletContext().setAttribute("org.apache.tomcat.WELCOME_FILES",
  +					 welcomeFiles);
  +
  +    }
  +
  +
  +    /**
        * Remove the specified security constraint from this web application.
        *
        * @param constraint Constraint to be removed
  @@ -1328,7 +1367,8 @@
        */
       public void removeWelcomeFile(String name) {
   
  -	welcomeFiles.remove(name);
  +	welcomeFiles.removeElement(name);
  +	postWelcomeFiles();
   	fireContainerEvent("removeWelcomeFile", name);
   
       }
  
  
  
  1.6       +41 -40    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardEngine.java
  
  Index: StandardEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardEngine.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StandardEngine.java	2000/04/26 02:14:50	1.5
  +++ StandardEngine.java	2000/04/29 05:59:54	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardEngine.java,v 1.5 2000/04/26 02:14:50 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/04/26 02:14:50 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardEngine.java,v 1.6 2000/04/29 05:59:54 craigmcc Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/04/29 05:59:54 $
    *
    * ====================================================================
    *
  @@ -81,7 +81,7 @@
    * fully qualified host name of that virtual host.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.5 $ $Date: 2000/04/26 02:14:50 $
  + * @version $Revision: 1.6 $ $Date: 2000/04/29 05:59:54 $
    */
   
   public final class StandardEngine
  @@ -107,7 +107,8 @@
   
   
       /**
  -     * Host name to use when no server host is specified in the request.
  +     * Host name to use when no server host, or an unknown host,
  +     * is specified in the request.
        */
       private String defaultHost = null;
   
  @@ -119,12 +120,6 @@
   	"org.apache.tomcat.core.StandardEngine/1.0";
   
   
  -    /**
  -     * Host name to use when an unknown host name is specified.
  -     */
  -    private String unknownHost = null;
  -
  -
       // ------------------------------------------------------------- Properties
   
   
  @@ -153,31 +148,6 @@
       }
   
   
  -    /**
  -     * Return the unknown host.
  -     */
  -    public String getUnknownHost() {
  -
  -	return (unknownHost);
  -
  -    }
  -
  -
  -    /**
  -     * Set the unknown host.
  -     *
  -     * @param host The new unknown host
  -     */
  -    public void setUnknownHost(String host) {
  -
  -	String oldUnknownHost = this.unknownHost;
  -	this.unknownHost = host;
  -	support.firePropertyChange("unknownHost", oldUnknownHost,
  -				   this.unknownHost);
  -
  -    }
  -
  -
       // --------------------------------------------------------- Public Methods
   
   
  @@ -220,16 +190,47 @@
       public Host map(Request request, boolean update) {
   
   	// Extract the requested server name
  -	String server = request.getRequest().getServerName();
  +	String server = request.getRequest().getServerName().toLowerCase();
   	if (server == null)
   	    server = defaultHost;
   	if (server == null)
   	    return (null);
  +	if (debug > 0)
  +	    log("Mapping server name '" + server + "'");
   
  -	// Find the matching child Host
  +	// Find the matching child Host directly
  +	if (debug > 1)
  +	    log(" Trying a direct match");
   	Host host = (Host) findChild(server);
  -	if ((host == null) && (unknownHost != null))
  -	    host = (Host) findChild(unknownHost);
  +
  +	// Find a matching Host by alias.  FIXME - Optimize this!
  +	if (host == null) {
  +	    if (debug > 1)
  +		log(" Trying an alias match");
  +	    Container children[] = findChildren();
  +	    for (int i = 0; i < children.length; i++) {
  +		String aliases[] = ((Host) children[i]).findAliases();
  +		for (int j = 0; j < aliases.length; j++) {
  +		    if (server.equals(aliases[j])) {
  +			host = (Host) children[i];
  +			break;
  +		    }
  +		}
  +		if (host != null)
  +		    break;
  +	    }
  +	}
  +
  +	// Trying the "default" host if any
  +	if (host == null) {
  +	    if (debug > 1)
  +		log(" Trying the default host");
  +	    host = (Host) findChild(defaultHost);
  +	}
  +
  +	// Complain if no host was found
  +	if (host == null)
  +	    log(sm.getString("standardEngine.mappingError", server));
   
   	// Update the request if requested, and return the selected host
   	;	// No update to the request is required
  
  
  
  1.8       +101 -5    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHost.java
  
  Index: StandardHost.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHost.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StandardHost.java	2000/04/26 02:14:50	1.7
  +++ StandardHost.java	2000/04/29 05:59:54	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHost.java,v 1.7 2000/04/26 02:14:50 craigmcc Exp $
  - * $Revision: 1.7 $
  - * $Date: 2000/04/26 02:14:50 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHost.java,v 1.8 2000/04/29 05:59:54 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2000/04/29 05:59:54 $
    *
    * ====================================================================
    *
  @@ -84,7 +84,7 @@
    * requests directed to a particular web application.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2000/04/26 02:14:50 $
  + * @version $Revision: 1.8 $ $Date: 2000/04/29 05:59:54 $
    */
   
   public final class StandardHost
  @@ -110,6 +110,12 @@
   
   
       /**
  +     * The set of aliases for this Host.
  +     */
  +    private String[] aliases = new String[0];
  +
  +
  +    /**
        * The descriptive information string for this implementation.
        */
       private static final String info =
  @@ -156,6 +162,8 @@
   	    throw new IllegalArgumentException
   		(sm.getString("standardHost.nullName"));
   
  +	name = name.toLowerCase();	// Internally all names are lower case
  +
   	String oldName = this.name;
   	this.name = name;
   	support.firePropertyChange("name", oldName, this.name);
  @@ -212,6 +220,33 @@
   
   
       /**
  +     * Add an alias name that should be mapped to this same Host.
  +     *
  +     * @param alias The alias to be added
  +     */
  +    public void addAlias(String alias) {
  +
  +	alias = alias.toLowerCase();
  +
  +	// Skip duplicate aliases
  +	for (int i = 0; i < aliases.length; i++) {
  +	    if (aliases[i].equals(alias))
  +		return;
  +	}
  +
  +	// Add this alias to the list
  +	String newAliases[] = new String[aliases.length + 1];
  +	for (int i = 0; i < aliases.length; i++)
  +	    newAliases[i] = aliases[i];
  +	newAliases[aliases.length] = alias;
  +
  +	// Inform interested listeners
  +	fireContainerEvent(ADD_ALIAS_EVENT, alias);
  +
  +    }
  +
  +
  +    /**
        * Add a child Container, only if the proposed child is an implementation
        * of Context.
        *
  @@ -228,6 +263,17 @@
   
   
       /**
  +     * Return the set of alias names for this Host.  If none are defined,
  +     * a zero length array is returned.
  +     */
  +    public String[] findAliases() {
  +
  +	return (this.aliases);
  +
  +    }
  +
  +
  +    /**
        * Return descriptive information about this Container implementation and
        * the corresponding version number, in the format
        * <code>&lt;description&gt;/&lt;version&gt;</code>.
  @@ -280,7 +326,12 @@
        */
       public Context map(String uri) {
   
  +	if (debug > 0)
  +	    log("Mapping request URI '" + uri + "'");
  +
   	// Match on the longest possible context path prefix
  +	if (debug > 1)
  +	    log("  Trying the longest context path prefix");
   	Context context = null;
   	while (true) {
   	    context = (Context) findChild(uri);
  @@ -293,11 +344,56 @@
   	}
   
   	// If no Context matches, select the default Context
  -	if (context == null)
  +	if (context == null) {
  +	    if (debug > 1)
  +		log("  Trying the default context");
   	    context = (Context) findChild("");
  +	}
   
  +	// Complain if no Context has been selected
  +	if (context == null) {
  +	    log(sm.getString("standardHost.mappingError", uri));
  +	    return (null);
  +	}
  +
   	// Return the mapped Context (if any)
  +	if (debug > 0)
  +	    log(" Mapped to context '" + context.getPath() + "'");
   	return (context);
  +
  +    }
  +
  +
  +    /**
  +     * Remove the specified alias name from the aliases for this Host.
  +     *
  +     * @param alias Alias name to be removed
  +     */
  +    public void removeAlias(String alias) {
  +
  +	alias = alias.toLowerCase();
  +
  +	// Make sure this alias is currently present
  +	int n = -1;
  +	for (int i = 0; i < aliases.length; i++) {
  +	    if (aliases[i].equals(alias)) {
  +		n = i;
  +		break;
  +	    }
  +	}
  +	if (n < 0)
  +	    return;
  +
  +	// Remove the specified alias
  +	int j = 0;
  +	String newAliases[] = new String[aliases.length - 1];
  +	for (int i = 0; i < aliases.length; i++) {
  +	    if (i != n)
  +		newAliases[j++] = aliases[i];
  +	}
  +
  +	// Inform interested listeners
  +	fireContainerEvent(REMOVE_ALIAS_EVENT, alias);
   
       }
   
  
  
  
  1.6       +44 -5     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapper.java
  
  Index: StandardWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapper.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StandardWrapper.java	2000/04/26 02:14:51	1.5
  +++ StandardWrapper.java	2000/04/29 05:59:54	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapper.java,v 1.5 2000/04/26 02:14:51 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/04/26 02:14:51 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapper.java,v 1.6 2000/04/29 05:59:54 craigmcc Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/04/29 05:59:54 $
    *
    * ====================================================================
    *
  @@ -96,7 +96,7 @@
    * make them efficient are counter-productive.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.5 $ $Date: 2000/04/26 02:14:51 $
  + * @version $Revision: 1.6 $ $Date: 2000/04/29 05:59:54 $
    */
   
   public final class StandardWrapper
  @@ -128,6 +128,12 @@
   
   
       /**
  +     * The debugging detail level for this component.
  +     */
  +    private int debug = 2;
  +
  +
  +    /**
        * The descriptive information string for this implementation.
        */
       private static final String info =
  @@ -184,6 +190,28 @@
   
   
       /**
  +     * Return the debugging detail level for this component.
  +     */
  +    public int getDebug() {
  +
  +	return (this.debug);
  +
  +    }
  +
  +
  +    /**
  +     * Set the debugging detail level for this component.
  +     *
  +     * @param debug The new debugging detail level
  +     */
  +    public void setDebug(int debug) {
  +
  +	this.debug = debug;
  +
  +    }
  +
  +
  +    /**
        * Return descriptive information about this Container implementation and
        * the corresponding version number, in the format
        * <code>&lt;description&gt;/&lt;version&gt;</code>.
  @@ -380,28 +408,39 @@
        */
       public Servlet allocate() {
   
  +	if (debug > 0)
  +	    log("Allocating an instance");
  +
   	// Load and initialize our instance if necessary
   	if (instance == null) {
   	    try {
   		load();
   	    } catch (Exception e) {
  +		log(sm.getString("standardWrapper.loadError", servletClass),
  +		    e);
   		return (null);
   	    }
   	}
   
   	// If not SingleThreadedModel, return the same instance every time
  -	if (!singleThreadModel)
  +	if (!singleThreadModel) {
  +	    log("  Returning non-STM instance");
   	    return (instance);
  +	}
   
   	// Lock and return this instance
   	synchronized (instance) {
   	    if (allocated) {
  +		if (debug > 1)
  +		    log("  Waiting for allocated STM instance");
   		try {
   		    instance.wait();
   		} catch (InterruptedException e) {
   		    ;
   		}
   	    }
  +	    if (debug > 1)
  +		log("  Returning allocated STM instance");
   	    allocated = true;
   	    return (instance);
   	}
  
  
  
  1.4       +62 -12    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java
  
  Index: StandardWrapperValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardWrapperValve.java	2000/04/23 01:42:35	1.3
  +++ StandardWrapperValve.java	2000/04/29 05:59:54	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java,v 1.3 2000/04/23 01:42:35 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/04/23 01:42:35 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java,v 1.4 2000/04/29 05:59:54 craigmcc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/04/29 05:59:54 $
    *
    * ====================================================================
    *
  @@ -74,6 +74,7 @@
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   import org.apache.tomcat.Container;
  +import org.apache.tomcat.Logger;
   import org.apache.tomcat.Request;
   import org.apache.tomcat.Response;
   import org.apache.tomcat.Wrapper;
  @@ -86,7 +87,7 @@
    * <code>StandardWrapper</code> container implementation.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2000/04/23 01:42:35 $
  + * @version $Revision: 1.4 $ $Date: 2000/04/29 05:59:54 $
    */
   
   final class StandardWrapperValve
  @@ -125,24 +126,73 @@
   	Servlet servlet = null;
   
   	try {
  -
   	    servlet = wrapper.allocate();
  -
   	    if ((servlet instanceof HttpServlet) &&
   		(sreq instanceof HttpServletRequest) &&
  -		(sres instanceof HttpServletResponse))
  +		(sres instanceof HttpServletResponse)) {
   		((HttpServlet) servlet).service((HttpServletRequest) sreq,
   						(HttpServletResponse) sres);
  -	    else
  +	    } else {
   		servlet.service(sreq, sres);
  -
  +	    }
   	    wrapper.deallocate(servlet);
  -
   	} catch (Throwable t) {
  -
  -	    ;	// FIXME - deal with exceptions thrown by the servlet
  +	    log(sm.getString("servletWrapper.servletException"), t);
   	    wrapper.deallocate(servlet);
  +	}
  +
  +    }
  +
  +
  +    // -------------------------------------------------------- Private Methods
  +
  +
  +    /**
  +     * Log a message on the Logger associated with our Container (if any)
  +     *
  +     * @param message Message to be logged
  +     */
  +    private void log(String message) {
  +
  +	Logger logger = null;
  +	if (container != null)
  +	    logger = container.getLogger();
  +	if (logger != null)
  +	    logger.log("StandardWrapperValve[" + container.getName() + "]: "
  +		       + message);
  +	else {
  +	    String containerName = null;
  +	    if (container != null)
  +		containerName = container.getName();
  +	    System.out.println("StandardWrapperValve[" + containerName
  +			       + "]: " + message);
  +	}
  +
  +    }
  +
  +
  +    /**
  +     * Log a message on the Logger associated with our Container (if any)
  +     *
  +     * @param message Message to be logged
  +     * @param throwable Associated exception
  +     */
  +    private void log(String message, Throwable throwable) {
   
  +	Logger logger = null;
  +	if (container != null)
  +	    logger = container.getLogger();
  +	if (logger != null)
  +	    logger.log("StandardWrapperValve[" + container.getName() + "] "
  +		       + message, throwable);
  +	else {
  +	    String containerName = null;
  +	    if (container != null)
  +		containerName = container.getName();
  +	    System.out.println("StandardWrapperValve[" + containerName
  +			       + "]: " + message);
  +	    System.out.println("" + throwable);
  +	    throwable.printStackTrace(System.out);
   	}
   
       }
  
  
  
  1.2       +32 -4     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/StandardLoader.java
  
  Index: StandardLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/StandardLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StandardLoader.java	2000/04/26 02:14:53	1.1
  +++ StandardLoader.java	2000/04/29 05:59:55	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/StandardLoader.java,v 1.1 2000/04/26 02:14:53 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/04/26 02:14:53 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/StandardLoader.java,v 1.2 2000/04/29 05:59:55 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/04/29 05:59:55 $
    *
    * ====================================================================
    *
  @@ -97,7 +97,7 @@
    * is not present, the system class loader will be used instead.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/04/26 02:14:53 $
  + * @version $Revision: 1.2 $ $Date: 2000/04/29 05:59:55 $
    */
   
   public final class StandardLoader
  @@ -120,6 +120,12 @@
   
   
       /**
  +     * The debugging detail level for this component.
  +     */
  +    private int debug = 0;
  +
  +
  +    /**
        * The descriptive information about this Loader implementation.
        */
       private static final String info =
  @@ -192,6 +198,28 @@
   	Container oldContainer = this.container;
   	this.container = container;
   	support.firePropertyChange("container", oldContainer, this.container);
  +
  +    }
  +
  +
  +    /**
  +     * Return the debugging detail level for this component.
  +     */
  +    public int getDebug() {
  +
  +	return (this.debug);
  +
  +    }
  +
  +
  +    /**
  +     * Set the debugging detail level for this component.
  +     *
  +     * @param debug The new debugging detail level
  +     */
  +    public void setDebug(int debug) {
  +
  +	this.debug = debug;
   
       }
   
  
  
  
  1.3       +11 -7     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/StandardResources.java
  
  Index: StandardResources.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/StandardResources.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StandardResources.java	2000/04/27 05:55:17	1.2
  +++ StandardResources.java	2000/04/29 05:59:55	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/StandardResources.java,v 1.2 2000/04/27 05:55:17 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/04/27 05:55:17 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/StandardResources.java,v 1.3 2000/04/29 05:59:55 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/04/29 05:59:55 $
    *
    * ====================================================================
    *
  @@ -101,7 +101,7 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/04/27 05:55:17 $
  + * @version $Revision: 1.3 $ $Date: 2000/04/29 05:59:55 $
    */
   
   public final class StandardResources
  @@ -346,9 +346,11 @@
        */
       public String getMimeType(String file) {
   
  +	if (debug > 0)
  +	    log("Calculating MIME type of '" + file + "'");
   	if (file == null)
   	    return (null);
  -	if ((container != null) || (!(container instanceof Context)))
  +	if ((container == null) || (!(container instanceof Context)))
   	    return (null);
   	int period = file.lastIndexOf(".");
   	if (period < 0)
  @@ -356,8 +358,10 @@
   	String extension = file.substring(period + 1);
   	if (extension.length() < 1)
   	    return (null);
  -	else
  -	    return (((Context) container).findMimeMapping(extension));
  +	if (debug > 0)
  +	    log(" Mime type of '" + extension + "' is '" +
  +		((Context) container).findMimeMapping(extension));
  +	return (((Context) container).findMimeMapping(extension));
   
       }
   
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java
  
  Index: DefaultServlet.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v 1.1 2000/04/29 05:59:56 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/04/29 05:59:56 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  
  package org.apache.tomcat.servlets;
  
  
  import java.io.BufferedInputStream;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.InputStream;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.sql.Timestamp;
  import java.util.Enumeration;
  import java.util.Vector;
  import javax.servlet.ServletException;
  import javax.servlet.ServletOutputStream;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.tomcat.util.xml.SaxContext;
  import org.apache.tomcat.util.xml.XmlAction;
  import org.apache.tomcat.util.xml.XmlMapper;
  
  
  /**
   * The default resource-serving servlet for most web applications,
   * used to serve static resources such as HTML pages and images.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/04/29 05:59:56 $
   */
  
  public final class DefaultServlet
      extends HttpServlet {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The debugging detail level for this servlet.
       */
      private int debug = 0;
  
  
      /**
       * The input buffer size to use when serving resources.
       */
      private int input = 2048;
  
  
      /**
       * The output buffer size to use when serving resources.
       */
      private int output = 2048;
  
  
      /**
       * The set of welcome files for this web application
       */
      private Vector welcomes = new Vector();
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Finalize this servlet.
       */
      public void destroy() {
  
  	;	// No actions necessary
  
      }
  
  
      /**
       * Process a GET request for the specified resource.
       *
       * @param request The servlet request we are processing
       * @param response The servlet response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet-specified error occurs
       */
      public void doGet(HttpServletRequest request,
  		      HttpServletResponse response)
  	throws IOException, ServletException {
  
  	// Serve the requested resource, including the data content
  	serveResource(request, response, true);
  
      }
  
  
      /**
       * Process a HEAD request for the specified resource.
       *
       * @param request The servlet request we are processing
       * @param response The servlet response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet-specified error occurs
       */
      /*
      public void doHead(HttpServletRequest request,
  		       HttpServletResponse response)
  	throws IOException, ServletException {
  
  	// Identify the requested resource path
  	String pathInfo = request.getPathInfo();
  	if (debug > 0)
  	    log("DefaultServlet.doHead:  Serving resource '" + pathInfo + "'");
  	if (pathInfo == null) {
  	    response.sendError(HttpServletResponse.SC_BAD_REQUEST);
  	    return;
  	}
  
  	// Serve the requested resource, without the data content
  	serveResource(request, response, false);
  
      }
      */
  
  
      /**
       * Process a POST request for the specified resource.
       *
       * @param request The servlet request we are processing
       * @param response The servlet response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet-specified error occurs
       */
      public void doPost(HttpServletRequest request,
  		       HttpServletResponse response)
  	throws IOException, ServletException {
  
  	doGet(request, response);
  
      }
  
  
      /**
       * Return the date and time that the specified resource was last modified,
       * in milliseconds since midnight January 1, 1970 GMT.  If the time is
       * unknown, a negative number is returned.
       *
       * @param request The servlet request we are processing
       */
      public long getLastModified(HttpServletRequest request) {
  
  	// Identify the requested resource path
  	String pathInfo = request.getPathInfo();
  	if (debug > 0)
  	    log("DefaultServlet.getLastModified:  Serving resource '" +
  		pathInfo + "'");
  	if (pathInfo == null)
  	    return (-1);
  
  	// Convert the resource path to a URL
  	URL resourceURL = null;
  	try {
  	    resourceURL = getServletContext().getResource(pathInfo);
  	} catch (MalformedURLException e) {
  	    ;
  	}
  	if (resourceURL == null)
  	    return (-1);
  	if (debug > 0)
  	    log("DefaultServlet.getLastModified:  Corresponding URL is '" +
  		resourceURL.toString() + "'");
  
  	// Optimized processing for a "file:" URL
  	if ("file".equals(resourceURL.getProtocol())) {
  	    File file = new File(resourceURL.getFile());
  	    if (file == null)
  		return (-1);
  	    if (!file.exists() || !file.canRead())
  		return (-1);
  	    if (debug > 0)
  		log("DefaultServlet.getLastModified:  Last modified on '" +
  		    new Timestamp(file.lastModified()) + "'");
  	    return (file.lastModified());
  	}
  
  	// Currently do not know how to answer this question for other URLs
  	return (-1);	// FIXME: getLastModified() for non-file URL
  
      }
  
  
      /**
       * Initialize this servlet.
       */
      public void init() throws ServletException {
  
  	// Set our properties from the initialization parameters
  	String value = null;
  	try {
  	    value = getServletConfig().getInitParameter("debug");
  	    debug = Integer.parseInt(value);
  	} catch (Throwable t) {
  	    ;
  	}
  	try {
  	    value = getServletConfig().getInitParameter("input");
  	    input = Integer.parseInt(value);
  	} catch (Throwable t) {
  	    ;
  	}
  	try {
  	    value = getServletConfig().getInitParameter("output");
  	    output = Integer.parseInt(value);
  	} catch (Throwable t) {
  	    ;
  	}
  
  	// Sanity check on the specified buffer sizes
  	if (input < 256)
  	    input = 256;
  	if (output < 256)
  	    output = 256;
  
  	// Initialize the set of welcome files for this application
  	welcomes = (Vector) getServletContext().getAttribute
  	    ("org.apache.tomcat.WELCOME_FILES");
  	if (welcomes == null)
  	    welcomes = new Vector();
  
  	if (debug > 0) {
  	    log("DefaultServlet.init:  input buffer size=" + input +
  		", output buffer size=" + output);
  	    for (int i = 0; i < welcomes.size(); i++)
  		log("DefaultServlet.init:  welcome file=" +
  		    welcomes.elementAt(i));
  	}
  
      }
  
  
  
      // -------------------------------------------------------- Private Methods
  
  
      /**
       * Copy the contents of the specified input stream to the specified
       * output stream, and ensure that both streams are closed before returning
       * (even in the face of an exception).
       *
       * @param istream The input stream to read from
       * @param ostream The output stream to write to
       *
       * @exception IOException if an input/output error occurs
       */
      private void copy(InputStream istream, ServletOutputStream ostream)
  	throws IOException {
  
  	// Copy the input stream to the output stream
  	IOException exception = null;
  	byte buffer[] = new byte[input];
  	int len = buffer.length;
  	while (len >= buffer.length) {
  	    try {
  		len = istream.read(buffer);
  		ostream.write(buffer, 0, len);
  	    } catch (IOException e) {
  		exception = e;
  		len = -1;
  	    }
  	    if (len < buffer.length)
  		break;
  	}
  
  	// Clean up the input and output streams
  	try {
  	    istream.close();
  	} catch (Throwable t) {
  	    ;
  	}
  	try {
  	    ostream.flush();
  	} catch (Throwable t) {
  	    ;
  	}
  	try {
  	    ostream.close();
  	} catch (Throwable t) {
  	    ;
  	}
  
  	// Rethrow any exception that has occurred
  	if (exception != null)
  	    throw exception;
  
      }
  
  
      /**
       * Serve the specified directory as a set of hyperlinks to the
       * included files.
       *
       * @param requestURI Request URI of the directory being served
       * @param directory File object representing this directory
       * @param response The servlet response we are creating
       * @param content Should the content be included?
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet-specified error occurs
       */
      public void serveDirectory(String requestURI, File directory,
  			       HttpServletResponse response,
  			       boolean content)
  	throws IOException, ServletException {
  
  	if (!content)
  	    return;
  
  	// FIXME - look for a welcome file
  
  	// FIXME - do the directory thing
  	response.setContentType("text/html");
  	response.setBufferSize(output);
  	PrintWriter writer = response.getWriter();
  
  	writer.println("<html>");
  
  	writer.println("<head>");
  	writer.println("<title>Directory of " + requestURI + "</title>");
  	writer.println("</head>");
  
  	writer.println("<body bgcolor=\"white\">");
  	writer.println("Files in this directory:");
  	writer.println("<ul>");
  	String filenames[] = directory.list();
  	for (int i = 0; i < filenames.length; i++) {
  	    writer.println("<li>" + filenames[i]);
  	}
  	writer.println("</ul>");
  	writer.println("</body>");
  
  	writer.println("</html>");
  	writer.flush();
  	writer.close();
  
      }
  
  
      /**
       * Serve the specified file, optionally including the data content.
       *
       * @param requestURI The request URI we are processing
       * @param pathname Pathname of the file to be served
       * @param response The servlet response we are creating
       * @param content Should the content be included?
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet-specified error occurs
       */
      public void serveFile(String requestURI, String pathname,
  			  HttpServletResponse response,
  			  boolean content)
  	throws IOException, ServletException {
  
  	// Open the file (if it actually exists)
  	File file = new File(pathname);
  	if (!file.exists() || !file.canRead()) {
  	    response.sendError(HttpServletResponse.SC_NOT_FOUND, pathname);
  	    return;
  	}
  	if (file.isDirectory()) {
  	    serveDirectory(requestURI, file, response, content);
  	    return;
  	}
  	InputStream istream =	// FIXME: internationalization???????
  	    new BufferedInputStream(new FileInputStream(pathname), input);
  
  	// Set the appropriate output headers
  	String contentType = getServletContext().getMimeType(pathname);
  	if (contentType != null) {
  	    if (debug > 0)
  		log("DefaultServlet.serveFile: contentType='" +
  		    contentType + "'");
  	    response.setContentType(contentType);
  	}
  	long contentLength = file.length();
  	if (contentLength >= 0) {
  	    if (debug > 0)
  		log("DefaultServlet.serveFile: contentLength=" +
  		    contentLength);
  	    response.setContentLength((int) contentLength);
  	}
  
  	// Copy the input stream to our output stream (if requested)
  	if (content) {
  	    response.setBufferSize(output);
  	    copy(istream, response.getOutputStream());
  	}
  
      }
  
  
      /**
       * Serve the specified resource, optionally including the data content.
       *
       * @param request The servlet request we are processing
       * @param response The servlet response we are creating
       * @param content Should the content be included?
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet-specified error occurs
       */
      public void serveResource(HttpServletRequest request,
  			      HttpServletResponse response,
  			      boolean content)
  	throws IOException, ServletException {
  
  	// Identify the requested resource path
  	String pathInfo = request.getPathInfo();
  	if (debug > 0) {
  	    if (content)
  		log("DefaultServlet.serveResource:  Serving resource '" +
  		    pathInfo + "' headers and data");
  	    else
  		log("DefaultServlet.serveResource:  Serving resource '" +
  		    pathInfo + "' headers only");
  	}
  	if (pathInfo == null) {
  	    response.sendError(HttpServletResponse.SC_BAD_REQUEST);
  	    return;
  	}
  
  	// Exclude any resource in the /WEB-INF subdirectory
  	if (pathInfo.startsWith("/WEB-INF")) {
  	    response.sendError(HttpServletResponse.SC_NOT_FOUND, pathInfo);
  	    return;
  	}
  
  	// Convert the resource path to a URL
  	URL resourceURL = null;
  	try {
  	    resourceURL = getServletContext().getResource(pathInfo);
  	} catch (MalformedURLException e) {
  	    ;
  	}
  	if (resourceURL == null) {
  	    response.sendError(HttpServletResponse.SC_NOT_FOUND, pathInfo);
  	    return;
  	}
  	if (debug > 0)
  	    log("DefaultServlet.serveResource:  Corresponding URL is '" +
  		resourceURL.toString() + "'");
  
  	// Optimized processing for a "file:" URL
  	if ("file".equals(resourceURL.getProtocol())) {
  	    serveFile(request.getRequestURI(), resourceURL.getFile(),
  		      response, content);
  	    return;
  	}
  
  
      }
  
  }
  
  
  
  1.7       +11 -4     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/Catalina.java
  
  Index: Catalina.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/Catalina.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Catalina.java	2000/04/27 05:55:20	1.6
  +++ Catalina.java	2000/04/29 05:59:56	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/Catalina.java,v 1.6 2000/04/27 05:55:20 craigmcc Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/04/27 05:55:20 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/Catalina.java,v 1.7 2000/04/29 05:59:56 craigmcc Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/04/29 05:59:56 $
    *
    * ====================================================================
    *
  @@ -88,7 +88,7 @@
    * </u>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.6 $ $Date: 2000/04/27 05:55:20 $
  + * @version $Revision: 1.7 $ $Date: 2000/04/29 05:59:56 $
    */
   
   public final class Catalina {
  @@ -236,6 +236,13 @@
   	mapper.addRule("Server/Engine/Host", mapper.setProperties());
   	mapper.addRule("Server/Engine/Host", mapper.addChild
   		       ("addChild", "org.apache.tomcat.Container"));
  +
  +	/* FIXME - Server/Engine/Alias
  +	mapper.addRule("Server/Engine/Alias",
  +		       mapper.methodSetter("addAlias", 1));
  +	mapper.addRule("Server/Engine/Alias",
  +		       mapper.methodParam(0));
  +	*/
   
   	mapper.addRule("Server/Engine/Host/Context", mapper.objectCreate
   		       ("org.apache.tomcat.core.StandardContext",
  
  
  
  1.4       +12 -4     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java
  
  Index: ContextConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ContextConfig.java	2000/04/27 05:55:20	1.3
  +++ ContextConfig.java	2000/04/29 05:59:56	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java,v 1.3 2000/04/27 05:55:20 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/04/27 05:55:20 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java,v 1.4 2000/04/29 05:59:56 craigmcc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/04/29 05:59:56 $
    *
    * ====================================================================
    *
  @@ -77,6 +77,7 @@
   import org.apache.tomcat.Logger;
   import org.apache.tomcat.Resources;
   import org.apache.tomcat.Wrapper;
  +import org.apache.tomcat.loader.StandardLoader;
   import org.apache.tomcat.resources.StandardResources;
   import org.apache.tomcat.session.StandardManager;
   import org.apache.tomcat.util.StringManager;
  @@ -91,7 +92,7 @@
    * resource for this web application.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2000/04/27 05:55:20 $
  + * @version $Revision: 1.4 $ $Date: 2000/04/29 05:59:56 $
    */
   
   public final class ContextConfig
  @@ -430,6 +431,13 @@
   
   	// Configure a mapper to read a web application deployment descriptor
   	XmlMapper mapper = createMapper();
  +
  +	// Add missing Loader component if necessary
  +	if (context.getLoader() == null) {
  +	    if (debug > 0)
  +		log(sm.getString("contextConfig.defaultLoader"));
  +	    context.setLoader(new StandardLoader());
  +	}
   
   	// Add missing Manager component if necessary
   	if (context.getManager() == null) {
  
  
  
  1.4       +1 -0      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/LocalStrings.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LocalStrings.properties	2000/04/27 05:55:20	1.3
  +++ LocalStrings.properties	2000/04/29 05:59:56	1.4
  @@ -5,6 +5,7 @@
   contextConfig.cce=Lifecycle event data object {0} is not a Context
   contextConfig.defaultClose=Error closing default web.xml
   contextConfig.defaultConfig=Configuration error in default web.xml
  +contextConfig.defaultLoader=Configuring default Loader
   contextConfig.defaultManager=Configuring default Manager
   contextConfig.defaultMissing=Missing default web.xml, using application web.xml only
   contextConfig.defaultParse=Parse error in default web.xml
  
  
  
  1.7       +4 -4      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/valves/AccessLogValve.java
  
  Index: AccessLogValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/valves/AccessLogValve.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AccessLogValve.java	2000/04/26 02:14:55	1.6
  +++ AccessLogValve.java	2000/04/29 05:59:57	1.7
  @@ -122,7 +122,7 @@
    * can be implemented.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.6 $ $Date: 2000/04/26 02:14:55 $
  + * @version $Revision: 1.7 $ $Date: 2000/04/29 05:59:57 $
    */
   
   public final class AccessLogValve
  @@ -521,13 +521,13 @@
   	    String timestamp =
   		new Timestamp(System.currentTimeMillis()).toString();
   	    StringBuffer temp = new StringBuffer("[");
  -	    temp.append(timestamp.substring(8, 2));		// Day
  +	    temp.append(timestamp.substring(8, 10));		// Day
   	    temp.append('/');
  -	    temp.append(lookup(timestamp.substring(5, 2)));	// Month
  +	    temp.append(lookup(timestamp.substring(5, 7)));	// Month
   	    temp.append('/');
   	    temp.append(timestamp.substring(0, 4));		// Year
   	    temp.append(':');
  -	    temp.append(timestamp.substring(11, 8));		// Time
  +	    temp.append(timestamp.substring(11, 19));		// Time
   	    temp.append(' ');
   	    temp.append("-0800");				// FIXME!!!
   	    temp.append(']');
  
  
  

Mime
View raw message