tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From go...@hyperreal.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Constants.java Container.java Context.java LookupResult.java RequestMapper.java
Date Fri, 05 Nov 1999 05:35:02 GMT
gonzo       99/11/04 21:35:01

  Modified:    src/share/org/apache/tomcat/core Tag: TOMCAT_J2EE_10F_102199
                        Constants.java Container.java Context.java
                        LookupResult.java RequestMapper.java
  Log:
  feature:
  
  	jsp "servlet name" is available via the following
  	request attribute:
  
  		org.apache.tomcat.servlet.resolved
  
  	if the referenced jsp file is registered (ie web.xml)
  	the associated <servlet-name> will be returned,
  	regardless as to if the request was resolved against
  	an associated map or against the file directly [note:
  	due to an implementation detail this was trivial]
  	where as an un-registered jsp file will reflect the
  	file path
  
  fix:
  
  	disable InvokerServlet
  
  	null pointer check - apm/indeer
  
  note:
  
  	examples: pass
  	tests: pass
  	watchdog: 1 test failure -> negativeBeanName
  
  	it looks as though the /examples/servlets/index.html
  	and /examples/jsp/index.html have been modified such
  	that the img tags render invalid image access:
  
  		before:
  
  			<td width="30"><img src="../images/execute.gif"></td>
  
  		after:
  
  			<td WIDTH="30"><img SRC="execute.gif" ></td>
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.4   +4 -4      jakarta-tomcat/src/share/org/apache/tomcat/core/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Constants.java,v
  retrieving revision 1.2.2.3
  retrieving revision 1.2.2.4
  diff -u -r1.2.2.3 -r1.2.2.4
  --- Constants.java	1999/11/05 00:42:57	1.2.2.3
  +++ Constants.java	1999/11/05 05:34:48	1.2.2.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Constants.java,v
1.2.2.3 1999/11/05 00:42:57 costin Exp $
  - * $Revision: 1.2.2.3 $
  - * $Date: 1999/11/05 00:42:57 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Constants.java,v
1.2.2.4 1999/11/05 05:34:48 gonzo Exp $
  + * $Revision: 1.2.2.4 $
  + * $Date: 1999/11/05 05:34:48 $
    *
    * ====================================================================
    *
  @@ -200,7 +200,7 @@
           public static final String ERROR_MESSAGE =
               "javax.servlet.error.message";
           public static final String RESOLVED_SERVLET =
  -            "javax.servlet.resolved";
  +            "org.apache.tomcat.servlet.resolved";
       }
   
       public static class Locale {
  
  
  
  1.1.2.3   +18 -9     jakarta-tomcat/src/share/org/apache/tomcat/core/Container.java
  
  Index: Container.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Container.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Container.java	1999/11/03 20:02:32	1.1.2.2
  +++ Container.java	1999/11/05 05:34:48	1.1.2.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Container.java,v
1.1.2.2 1999/11/03 20:02:32 costin Exp $
  - * $Revision: 1.1.2.2 $
  - * $Date: 1999/11/03 20:02:32 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Container.java,v
1.1.2.3 1999/11/05 05:34:48 gonzo Exp $
  + * $Revision: 1.1.2.3 $
  + * $Date: 1999/11/05 05:34:48 $
    *
    * ====================================================================
    *
  @@ -266,7 +266,7 @@
   	if (sw != null &&
   	    (path.length() > 0)) {
   	    if (path.startsWith("/") &&
  -                path.endsWith("/*")){ 
  +                path.endsWith("/*")){
   	        prefixMappedServlets.put(path, sw);
   	    } else if (path.startsWith("*.")) {
   	        extensionMappedServlets.put(path, sw);
  @@ -295,7 +295,7 @@
       }
   
       LookupResult lookupServlet(String lookupPath) {
  -        RequestMapper requestMapper = new RequestMapper();
  +        RequestMapper requestMapper = new RequestMapper(this);
   
   	requestMapper.setPathMaps(pathMappedServlets);
   	requestMapper.setPrefixMaps(prefixMappedServlets);
  @@ -304,7 +304,7 @@
   	LookupResult lookupResult =
   	    requestMapper.lookupServlet(lookupPath);
   
  -	if (lookupResult == null) {
  +        if (lookupResult == null) {
   	    ServletWrapper wrapper = null;
   
   	    if (defaultServlet != null) {
  @@ -369,6 +369,11 @@
           // XXX
           // check for duplicates!
   
  +        if (servlets.get(name) != null) {
  +            removeServlet(name);
  +            removeServletByName(name);
  +        }
  +
           ServletWrapper wrapper = new ServletWrapper(this);
   
   	wrapper.setServletName(name);
  @@ -438,9 +443,10 @@
   	while (enum.hasMoreElements()) {
   	    String key = (String)enum.nextElement();
   	    ServletWrapper sw = (ServletWrapper)servlets.get(key);
  +
   
  -	    if (sw.getServletClass() != null &&
  -	        sw.getServletClass().equals(name)) {
  +            if (sw.getServletClass() != null &&
  +                sw.getServletClass().equals(name)) {
   	        servletWrappers.addElement(sw);
   	    }
   	}
  @@ -452,8 +458,11 @@
   
           return wrappers;
       }
  +
  +    // XXX
  +    // made package protected so that RequestMapper can have access
   
  -    private ServletWrapper[] getServletsByPath(String path) {
  +    ServletWrapper[] getServletsByPath(String path) {
           Vector servletWrappers = new Vector();
   	Enumeration enum = servlets.keys();
   
  
  
  
  1.5.2.6   +7 -4      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.5.2.5
  retrieving revision 1.5.2.6
  diff -u -r1.5.2.5 -r1.5.2.6
  --- Context.java	1999/11/03 20:02:33	1.5.2.5
  +++ Context.java	1999/11/05 05:34:48	1.5.2.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v 1.5.2.5
1999/11/03 20:02:33 costin Exp $
  - * $Revision: 1.5.2.5 $
  - * $Date: 1999/11/03 20:02:33 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v 1.5.2.6
1999/11/05 05:34:48 gonzo Exp $
  + * $Revision: 1.5.2.6 $
  + * $Date: 1999/11/05 05:34:48 $
    *
    * ====================================================================
    *
  @@ -635,7 +635,10 @@
   	request.setServletPath(result.getServletPath());
   	request.setPathInfo(result.getPathInfo());
   
  -        if (result.getMappedPath() != null) {
  +        if (result.getResolvedServlet() != null) {
  +            request.setAttribute(Constants.Attribute.RESOLVED_SERVLET,
  +                result.getResolvedServlet());
  +        } else if (result.getMappedPath() != null) {
               request.setAttribute(Constants.Attribute.RESOLVED_SERVLET,
                   result.getMappedPath());
           } else {
  
  
  
  1.1.2.1   +15 -6     jakarta-tomcat/src/share/org/apache/tomcat/core/LookupResult.java
  
  Index: LookupResult.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/LookupResult.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- LookupResult.java	1999/10/09 00:30:14	1.1
  +++ LookupResult.java	1999/11/05 05:34:49	1.1.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/LookupResult.java,v
1.1 1999/10/09 00:30:14 duncan Exp $
  - * $Revision: 1.1 $
  - * $Date: 1999/10/09 00:30:14 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/LookupResult.java,v
1.1.2.1 1999/11/05 05:34:49 gonzo Exp $
  + * $Revision: 1.1.2.1 $
  + * $Date: 1999/11/05 05:34:49 $
    *
    * ====================================================================
    *
  @@ -76,20 +76,25 @@
       private String servletPath = null;
       private String mappedPath = null;
       private String pathInfo = null;
  +    private String resolvedServlet = null;
   
       LookupResult(ServletWrapper wrapper, String servletPath,
           String pathInfo) {
  -	this.wrapper = wrapper;
  -	this.servletPath = servletPath;
  -	this.pathInfo = pathInfo;
  +        this(wrapper, servletPath, null, pathInfo, null);
       }
   
       LookupResult(ServletWrapper wrapper, String servletPath,
           String mappedPath, String pathInfo) {
  +        this(wrapper, servletPath, mappedPath, pathInfo, null);
  +    }
  +
  +    LookupResult(ServletWrapper wrapper, String servletPath,
  +        String mappedPath, String pathInfo, String resolvedServlet) {
   	this.wrapper = wrapper;
   	this.servletPath = servletPath;
   	this.mappedPath = mappedPath;
   	this.pathInfo = pathInfo;
  +	this.resolvedServlet = resolvedServlet;
       }
   
       ServletWrapper getWrapper() {
  @@ -106,5 +111,9 @@
   
       String getPathInfo() {
   	return pathInfo;
  +    }
  +
  +    String getResolvedServlet() {
  +	return resolvedServlet;
       }
   }
  
  
  
  1.2.2.4   +23 -6     jakarta-tomcat/src/share/org/apache/tomcat/core/RequestMapper.java
  
  Index: RequestMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestMapper.java,v
  retrieving revision 1.2.2.3
  retrieving revision 1.2.2.4
  diff -u -r1.2.2.3 -r1.2.2.4
  --- RequestMapper.java	1999/11/05 00:43:02	1.2.2.3
  +++ RequestMapper.java	1999/11/05 05:34:49	1.2.2.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestMapper.java,v
1.2.2.3 1999/11/05 00:43:02 costin Exp $
  - * $Revision: 1.2.2.3 $
  - * $Date: 1999/11/05 00:43:02 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestMapper.java,v
1.2.2.4 1999/11/05 05:34:49 gonzo Exp $
  + * $Revision: 1.2.2.4 $
  + * $Date: 1999/11/05 05:34:49 $
    *
    * ====================================================================
    *
  @@ -74,6 +74,7 @@
    */
   
   public class RequestMapper {
  +    private Container container = null;
       private Hashtable prefixMaps = null;
       private Hashtable extensionMaps = null;
       private Hashtable pathMaps = null;
  @@ -82,7 +83,8 @@
       private String pathInfo = null;
       private String resourceName = null;
   
  -    RequestMapper() {
  +    RequestMapper(Container container) {
  +        this.container = container;
       }
   
       void setPathMaps(Hashtable pathMaps) {
  @@ -103,9 +105,11 @@
   
   	if (wrapper != null) {
               this.mapPath = getMapPath(wrapper);
  +            String resolvedServlet = getResolvedServlet(this.mapPath);
   
               lookupResult = new LookupResult(wrapper,
  -                this.servletPath, this.mapPath, this.pathInfo);
  +                this.servletPath, this.mapPath, this.pathInfo,
  +                resolvedServlet);
           }
   
   	return lookupResult;
  @@ -237,7 +241,8 @@
               this.resourceName = this.servletPath;
   
               while (stillSearching) {
  -                if (wrapper.getPath() != null &&
  +                if (wrapper != null &&
  +                    wrapper.getPath() != null &&
                       wrapper.getServletClass() == null) {
                           this.resourceName = wrapper.getPath();
                           wrapper = getMatch(wrapper.getPath() +
  @@ -294,5 +299,17 @@
           }
   
           return mapPath;
  +    }
  +
  +    private String getResolvedServlet(String path) {
  +        String resolvedServlet = null;
  +        ServletWrapper[] sw = this.container.getServletsByPath(path);
  +
  +        if (sw.length > 0) {
  +            // assume one
  +            resolvedServlet = sw[0].getServletName();
  +        }
  +
  +        return resolvedServlet;
       }
   }
  
  
  

Mime
View raw message