You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@locus.apache.org on 2000/03/28 02:04:03 UTC
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java RequestImpl.java
costin 00/03/27 16:04:03
Modified: src/share/org/apache/tomcat/context WebXmlReader.java
src/share/org/apache/tomcat/core Context.java
RequestImpl.java
Log:
Fixed "welcome list", thanks msanchez@liaison.com for finding the bug.
Also, fixed getPathTranslated() ( return null if no path info exists )
Revision Changes Path
1.17 +2 -0 jakarta-tomcat/src/share/org/apache/tomcat/context/WebXmlReader.java
Index: WebXmlReader.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/WebXmlReader.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- WebXmlReader.java 2000/03/16 20:43:23 1.16
+++ WebXmlReader.java 2000/03/28 00:04:02 1.17
@@ -45,6 +45,8 @@
throw new TomcatException("Can't find default web.xml configuration");
processFile(ctx, default_xml.toString());
+ ctx.expectUserWelcomeFiles();
+
File inf_xml = new File(ctx.getDocBase() + "/WEB-INF/web.xml");
// if relative, base it to cm.home
if (!inf_xml.isAbsolute())
1.74 +19 -0 jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
Index: Context.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- Context.java 2000/03/27 23:03:32 1.73
+++ Context.java 2000/03/28 00:04:02 1.74
@@ -112,6 +112,8 @@
// -------------------- from web.xml
private Hashtable initializationParameters = new Hashtable();
+ // all welcome files that are added are treated as "system default"
+ private boolean expectUserWelcomeFiles=false;
private Vector welcomeFiles = new Vector();
private Hashtable errorPages = new Hashtable();
private String description = null;
@@ -218,6 +220,7 @@
}
// -------------------- Web.xml properties --------------------
+
public Enumeration getWelcomeFiles() {
return welcomeFiles.elements();
}
@@ -231,7 +234,23 @@
this.welcomeFiles.removeAllElements();
}
+ /** If any new welcome file is added, remove the old list of
+ * welcome files and start a new one. This is used as a hack to
+ * allow a default web.xml file to specifiy welcome files.
+ * We should use a better mechanism!
+ */
+ public void expectUserWelcomeFiles() {
+ expectUserWelcomeFiles = true;
+ }
+
+
public void addWelcomeFile( String s) {
+ // user specified at least one user welcome file, remove the system
+ // files
+ if( expectUserWelcomeFiles ) {
+ removeWelcomeFiles();
+ expectUserWelcomeFiles=false;
+ }
welcomeFiles.addElement( s );
}
1.24 +29 -15 jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java
Index: RequestImpl.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- RequestImpl.java 2000/03/21 00:32:39 1.23
+++ RequestImpl.java 2000/03/28 00:04:02 1.24
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java,v 1.23 2000/03/21 00:32:39 costin Exp $
- * $Revision: 1.23 $
- * $Date: 2000/03/21 00:32:39 $
+ * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java,v 1.24 2000/03/28 00:04:02 costin Exp $
+ * $Revision: 1.24 $
+ * $Date: 2000/03/28 00:04:02 $
*
* ====================================================================
*
@@ -101,7 +101,10 @@
protected String servletPath;
protected String pathInfo;
protected String pathTranslated;
-
+ // Need to distinguish between null pathTranslated and
+ // lazy-computed pathTranlsated
+ protected boolean pathTranslatedIsSet=false;
+
protected Hashtable parameters = new Hashtable();
protected int contentLength = -1;
protected String contentType = null;
@@ -247,27 +250,36 @@
return contentType;
}
+ /** All adapters that know the PT needs to call this method,
+ in order to set pathTranslatedIsSet, otherwise tomcat
+ will try to compute it again
+ */
public void setPathTranslated(String s ) {
pathTranslated=s;
+ pathTranslatedIsSet=true;
}
public String getPathTranslated() {
- // This is the correct Path_translated, previous implementation returned
- // the real path for this ( i.e. the URI ).
+ if( pathTranslatedIsSet ) return pathTranslated;
- // Check the PATH_TRANSLATED specs before changing!
- if( pathTranslated==null) {
- String path=getPathInfo();
- if(path==null) path="";
- pathTranslated=context.getRealPath( path );
- }
+ // not set yet - we'll compute it
+ pathTranslatedIsSet=true;
+ String path=getPathInfo();
+ // In CGI spec, PATH_TRANSLATED shouldn't be set if no path info is present
+ pathTranslated=null;
+ if(path==null || "".equals( path ) ) return null;
+ pathTranslated=context.getRealPath( path );
return pathTranslated;
}
+ // XXX XXX Servlet API conflicts with the CGI specs -
+ // PathInfo should be "" if no path info is requested ( as it is in CGI ).
+ // We are following the spec, but IMHO it's a bug ( in the spec )
public String getPathInfo() {
return pathInfo;
}
+
public void setRemoteUser(String s) {
remoteUser=s;
}
@@ -493,7 +505,6 @@
public void setPathInfo(String pathInfo) {
- ///*DEBUG*/ try {throw new Exception(); } catch(Exception ex) {ex.printStackTrace();}
this.pathInfo = pathInfo;
}
@@ -593,7 +604,7 @@
didCookies = false;
container=null;
handler=null;
- jvmRoute = null;
+ jvmRoute = null;
scheme = "http";// no need to use Constants
method = "GET";
requestURI="/";
@@ -602,7 +613,10 @@
headers.clear(); // XXX use recycle pattern
serverName="localhost";
serverPort=8080;
-
+ pathTranslated=null;
+ pathInfo=null;
+ pathTranslatedIsSet=false;
+
// XXX a request need to override those if it cares
// about security
remoteAddr="127.0.0.1";