You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@locus.apache.org on 2000/05/14 04:29:02 UTC
cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup Catalina.java
craigmcc 00/05/13 19:29:02
Modified: proposals/catalina/src/conf server.xml web.xml
proposals/catalina/src/share/org/apache/tomcat/loader
FileClassLoader.java
proposals/catalina/src/share/org/apache/tomcat/logger
LocalStrings.properties
proposals/catalina/src/share/org/apache/tomcat/servlets
DefaultServlet.java
proposals/catalina/src/share/org/apache/tomcat/startup
Catalina.java
Added: proposals/catalina/src/share/org/apache/tomcat/logger
TomcatLogger.java
Log:
Clean up handling of JSP pages as welcome files. Previously, it was
serving the text -- now it does a RequestDispatcher.forward() so that the
JSP page is evaluated as usual.
Add a Tomcat 3.x-compatible Logger mechanism for JASPER_LOG, until the JSP
runtime system is modified. IMHO this should not be dependent on Tomcat
internals at all -- rather, it should use the ServletContext.log() call --
but that's not a change that needs to happen right away.
Note: It was necessary to implement this by creating a load-on-startup
servlet that registered the logger in the static variables associated with
the correct class loader. This is a classic example of why trying to use
the Singleton design pattern across web apps is a bad idea!
Revision Changes Path
1.25 +15 -1 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.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- server.xml 2000/05/13 01:12:20 1.24
+++ server.xml 2000/05/14 02:28:59 1.25
@@ -8,7 +8,7 @@
<Connector className="org.apache.tomcat.connector.test.HttpConnector"
port="8080" minProcessors="5" maxProcessors="60"
- acceptCount="5" debug="0"/>
+ acceptCount="10" debug="0"/>
<!-- Define the top level container in our container hierarchy -->
@@ -95,6 +95,20 @@
prefix="localhost_servlet-tests_log." suffix=".txt"
timestamp="true"/>
</Context>
+
+ <!-- Struts Example Context -->
+<!--
+ <Context path="/struts" docBase="/home/cmcclanahan/Source/build/struts"
+ debug="0">
+ <Listener className="org.apache.tomcat.startup.ContextConfig"
+ debug="0"/>
+ <Loader className="org.apache.tomcat.loader.StandardLoader"
+ debug="2"/>
+ <Logger className="org.apache.tomcat.logger.FileLogger"
+ prefix="localhost_struts_log." suffix=".txt"
+ timestamp="true"/>
+ </Context>
+-->
</Host>
1.9 +21 -1 jakarta-tomcat/proposals/catalina/src/conf/web.xml
Index: web.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/conf/web.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- web.xml 2000/05/05 18:25:02 1.8
+++ web.xml 2000/05/14 02:28:59 1.9
@@ -30,6 +30,25 @@
</init-param>
</servlet>
+ <!-- The JASPER_LOG logger creation servlet -->
+ <servlet>
+ <servlet-name>jasper_log</servlet-name>
+ <servlet-class>org.apache.tomcat.servlets.TomcatLogServlet</servlet-class>
+ <load-on-startup>3</load-on-startup>
+ <init-param>
+ <param-name>name</param-name>
+ <param-value>JASPER_LOG</param-value>
+ </init-param>
+ <init-param>
+ <param-name>path</param-name>
+ <param-value>logs/jasper.log</param-value>
+ </init-param>
+ <init-param>
+ <param-name>verbosityLevel</param-name>
+ <param-value>DEBUG</param-value>
+ </init-param>
+ </servlet>
+
<!-- The JSP page compiler and execution servlet -->
<servlet>
<servlet-name>jsp</servlet-name>
@@ -42,9 +61,10 @@
</init-param>
-->
<!--
- <load-on-startup>3</load-on-startup>
+ <load-on-startup>4</load-on-startup>
-->
</servlet>
+
<!-- The mapping for the default servlet -->
<servlet-mapping>
1.4 +36 -4 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/FileClassLoader.java
Index: FileClassLoader.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/FileClassLoader.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FileClassLoader.java 2000/05/12 21:59:33 1.3
+++ FileClassLoader.java 2000/05/14 02:29:00 1.4
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/FileClassLoader.java,v 1.3 2000/05/12 21:59:33 craigmcc Exp $
- * $Revision: 1.3 $
- * $Date: 2000/05/12 21:59:33 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/loader/FileClassLoader.java,v 1.4 2000/05/14 02:29:00 craigmcc Exp $
+ * $Revision: 1.4 $
+ * $Date: 2000/05/14 02:29:00 $
*
* ====================================================================
*
@@ -94,7 +94,7 @@
* modified at runtime.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.3 $ $Date: 2000/05/12 21:59:33 $
+ * @version $Revision: 1.4 $ $Date: 2000/05/14 02:29:00 $
*/
public final class FileClassLoader
@@ -519,6 +519,21 @@
// if (debug >= 2)
// log("loadClass(" + name + ", " + resolve + ")");
+ // Handle server classes in a special way to preserve statics
+ if (server(name)) {
+ // if (debug >= 2)
+ // log(" Checking the server class path");
+ Class theClass = findSystemClass(name);
+ // if ((theClass != null) && (debug >= 2))
+ // log(" Loaded from the server class path");
+ if (theClass != null) {
+ return (theClass);
+ }
+ // if (debug >= 2)
+ // log(" Cannot find this server class");
+ throw new ClassNotFoundException(name);
+ }
+
// Has this class already been loaded?
CacheEntry entry = (CacheEntry) cache.get(name);
if (entry != null) {
@@ -915,6 +930,23 @@
System.out.println("FileClassLoader: " + message);
throwable.printStackTrace(System.out);
+
+ }
+
+
+ /**
+ * Is this a server class that should always be loaded specially?
+ *
+ * @param name Name of the class to be checked
+ */
+ private boolean server(String name) {
+
+ if (name.startsWith("org.apache.jasper."))
+ return (true);
+ else if (name.startsWith("org.apache.tomcat."))
+ return (true);
+ else
+ return (false);
}
1.3 +2 -0 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/logger/LocalStrings.properties
Index: LocalStrings.properties
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/logger/LocalStrings.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LocalStrings.properties 2000/01/29 03:47:29 1.2
+++ LocalStrings.properties 2000/05/14 02:29:00 1.3
@@ -1,2 +1,4 @@
fileLogger.alreadyStarted=File Logger has already been started
fileLogger.notStarted=File Logger has not yet been started
+tomcatLogger.alreadyStarted=Tomcat Logger has already been started
+tomcatLogger.notStarted=Tomcat Logger has not yet been started
1.1 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/logger/TomcatLogger.java
Index: TomcatLogger.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/logger/TomcatLogger.java,v 1.1 2000/05/14 02:29:00 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2000/05/14 02:29:00 $
*
* ====================================================================
*
* 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.logger;
import java.io.File;
/**
* Implementation of a Tomcat 3.x-compatible TomcatLogger for use by the
* JSP runtime system (until Jasper is converted).
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2000/05/14 02:29:00 $
*/
public final class TomcatLogger
extends org.apache.tomcat.logging.TomcatLogger {
/**
* If a relative path is specified, resolve it based on the Catalina
* home directory.
*
* @param path Path of the log file to create
*/
public void setPath(String path) {
File file = new File(path);
if (!file.isAbsolute()) {
file = new File(System.getProperty("catalina.home"), path);
path = file.getAbsolutePath();
}
super.setPath(path);
}
}
1.5 +29 -7 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java
Index: DefaultServlet.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultServlet.java 2000/05/01 01:53:55 1.4
+++ DefaultServlet.java 2000/05/14 02:29:01 1.5
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v 1.4 2000/05/01 01:53:55 craigmcc Exp $
- * $Revision: 1.4 $
- * $Date: 2000/05/01 01:53:55 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v 1.5 2000/05/14 02:29:01 craigmcc Exp $
+ * $Revision: 1.5 $
+ * $Date: 2000/05/14 02:29:01 $
*
* ====================================================================
*
@@ -76,6 +76,7 @@
import java.sql.Timestamp;
import java.util.Enumeration;
import java.util.Vector;
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
@@ -91,7 +92,7 @@
* used to serve static resources such as HTML pages and images.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.4 $ $Date: 2000/05/01 01:53:55 $
+ * @version $Revision: 1.5 $ $Date: 2000/05/14 02:29:01 $
*/
public final class DefaultServlet
@@ -321,14 +322,35 @@
if (!content)
return;
- // Serve a welcome file if one exists
+ // Remember the servlet path that got us here (plus a trailing slash)
+ String servletPath = request.getServletPath();
+ if (servletPath == null)
+ servletPath = "/";
+ if (!servletPath.endsWith("/"))
+ servletPath += "/";
+
+ // Serve a welcome resource or file if one exists
// FIXME - update the welcome files list?
for (int i = 0; i < welcomes.size(); i++) {
+
+ // Does the specified resource exist?
File file = new File(directory, (String) welcomes.elementAt(i));
- if (file.exists() && file.canRead() && file.isFile()) {
- serveFile(request, response, file.getAbsolutePath(), content);
+ if (!file.exists() || !file.canRead() || !file.isFile())
+ continue;
+
+ // Can we dispatch a request for this resource (i.e. JSP page)?
+ String resource = servletPath + (String) welcomes.elementAt(i);
+ RequestDispatcher rd =
+ getServletContext().getRequestDispatcher(resource);
+ if (rd != null) {
+ rd.forward(request, response);
return;
}
+
+ // Can we serve a file for this resource?
+ serveFile(request, response, file.getAbsolutePath(), content);
+ return;
+
}
1.9 +15 -6 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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Catalina.java 2000/05/05 22:45:40 1.8
+++ Catalina.java 2000/05/14 02:29:01 1.9
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/Catalina.java,v 1.8 2000/05/05 22:45:40 craigmcc Exp $
- * $Revision: 1.8 $
- * $Date: 2000/05/05 22:45:40 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/Catalina.java,v 1.9 2000/05/14 02:29:01 craigmcc Exp $
+ * $Revision: 1.9 $
+ * $Date: 2000/05/14 02:29:01 $
*
* ====================================================================
*
@@ -90,7 +90,7 @@
* </u>
*
* @author Craig R. McClanahan
- * @version $Revision: 1.8 $ $Date: 2000/05/05 22:45:40 $
+ * @version $Revision: 1.9 $ $Date: 2000/05/14 02:29:01 $
*/
public final class Catalina {
@@ -106,6 +106,12 @@
/**
+ * Set the debugging detail level on our XmlMapper.
+ */
+ private boolean debug = false;
+
+
+ /**
* The server component we are starting or stopping
*/
private Server server = null;
@@ -179,6 +185,8 @@
isConfig = false;
} else if (args[i].equals("-config")) {
isConfig = true;
+ } else if (args[i].equals("-debug")) {
+ debug = true;
} else if (args[i].equals("-help")) {
usage();
return (false);
@@ -217,7 +225,8 @@
// Initialize the mapper
XmlMapper mapper = new XmlMapper();
- mapper.setDebug(999);
+ if (debug)
+ mapper.setDebug(999);
// Configure the actions we will be using
@@ -541,7 +550,7 @@
private void usage() {
System.out.println("usage: java org.apache.tomcat.startup.Catalina" +
- " [ -config {pathname} ] { start | stop }");
+ " [ -config {pathname} ] [ -debug ] { start | stop }");
}