tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/service Ajp22ConnectionHandler.java
Date Fri, 07 Jan 2000 19:14:17 GMT
costin      00/01/07 11:14:16

  Modified:    src/share/org/apache/tomcat/core ApplicationSession.java
                        Container.java Context.java ContextManager.java
                        HttpServletRequestFacade.java Request.java
                        RequestDispatcherImpl.java
                        ServerSessionManager.java ServletContextFacade.java
                        ServletWrapper.java
               src/share/org/apache/tomcat/server ConnectionHandler.java
               src/share/org/apache/tomcat/service
                        Ajp22ConnectionHandler.java
  Added:       src/share/org/apache/tomcat/core RequestInterceptor.java
               src/share/org/apache/tomcat/request ContextInterceptor.java
                        MapperInterceptor.java SessionInterceptor.java
  Removed:     src/share/org/apache/tomcat/core RequestMapper.java
  Log:
  Probably the most dangerous patch, a lot of deep changes.
  
  - Removed RequestMapper and most of the parsing code from ContextManager,
  use request/xxxInterceptor.
  - made all the changes to glue back everything
  - use HttpSession instead of ServerSession in Request ( so Craig can put
  it's own implementation - next patch probably will move session out )
  - few cosmetic changes for code readability
  - made some methods public - need to sync with Craig's interfaces ( after
  everything is stable again ).
  
  Notes:
  - Interceptors are hardcoded in, configuration is a bit later.
  - I moved the request parsing outside of core to make both more readable,
  and to allow other to commit new parsers without worry about core.
  Same will happen with sessions.
  - it passes the tests ( incl. watchdog), but it's certain something is
  broken :-)
  
  Revision  Changes    Path
  1.2       +7 -3      jakarta-tomcat/src/share/org/apache/tomcat/core/ApplicationSession.java
  
  Index: ApplicationSession.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ApplicationSession.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ApplicationSession.java	1999/10/09 00:29:58	1.1
  +++ ApplicationSession.java	2000/01/07 19:14:10	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ApplicationSession.java,v 1.1 1999/10/09 00:29:58 duncan Exp $
  - * $Revision: 1.1 $
  - * $Date: 1999/10/09 00:29:58 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ApplicationSession.java,v 1.2 2000/01/07 19:14:10 costin Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/01/07 19:14:10 $
    *
    * ====================================================================
    * 
  @@ -104,6 +104,10 @@
           if (this.inactiveInterval != -1) {
               this.inactiveInterval *= 60;
           }
  +    }
  +
  +    ServerSession getServerSession() {
  +	return serverSession;
       }
   
       /**
  
  
  
  1.8       +69 -72    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Container.java	2000/01/07 18:48:34	1.7
  +++ Container.java	2000/01/07 19:14:10	1.8
  @@ -203,8 +203,7 @@
       void removeServletByName(String servletName) {
   	ServletWrapper wrapper=(ServletWrapper)servlets.get(servletName);
   	if( wrapper != null ) {
  -	    ServletWrapper wa[]={wrapper};
  -	    removeServlets( wa );
  +	    removeServlet( wrapper );
   	}
       }
   
  @@ -216,7 +215,17 @@
       }
   
       void removeJSP(String path) {
  -        removeServlets(getServletsByPath(path));
  +	Enumeration enum = servlets.keys();
  +
  +	while (enum.hasMoreElements()) {
  +	    String key = (String)enum.nextElement();
  +	    ServletWrapper sw = (ServletWrapper)servlets.get(key);
  +
  +	    if (sw.getPath() != null &&
  +	        sw.getPath().equals(path)) {
  +	        removeServlet( sw );
  +	    }
  +	}
       }
   
       public void setServletInitParams(String name, Hashtable initParams) {
  @@ -274,6 +283,22 @@
   	}
       }
   
  +    public ServletWrapper getDefaultServlet() {
  +	return defaultServlet;
  +    }
  +    
  +    public Hashtable getPathMap() {
  +	return pathMappedServlets;
  +    }
  +
  +    public Hashtable getPrefixMap() {
  +	return prefixMappedServlets;
  +    }
  +
  +    public Hashtable getExtensionMap() {
  +	return extensionMappedServlets;
  +    }
  +    
       boolean containsMapping(String mapping) {
           mapping = mapping.trim();
   
  @@ -290,38 +315,6 @@
   	pathMappedServlets.remove(mapping);
       }
   
  -    Request lookupServlet(String lookupPath) {
  -        RequestMapper requestMapper = new RequestMapper(this);
  -
  -	requestMapper.setPathMaps(pathMappedServlets);
  -	requestMapper.setPrefixMaps(prefixMappedServlets);
  -	requestMapper.setExtensionMaps(extensionMappedServlets);
  -
  -	Request lookupResult =
  -	    requestMapper.lookupServlet(lookupPath);
  -
  -        if (lookupResult == null) {
  -	    ServletWrapper wrapper = null;
  -
  -	    if (defaultServlet != null) {
  -	        wrapper = defaultServlet;
  -	    } else {
  -	        wrapper = (ServletWrapper)servlets.get(
  -		    Constants.Servlet.Default.Name);
  -	    }
  -
  -	    String servletPath = Constants.Servlet.Default.Map;
  -            String pathInfo = lookupPath;
  -
  -	    lookupResult = new Request();
  -	    lookupResult.setWrapper( wrapper );
  -	    lookupResult.setServletPath( servletPath );
  -	    lookupResult.setPathInfo( pathInfo );
  -	}
  -
  -	return lookupResult;
  -    }
  -
       Request lookupServletByName(String servletName) {
           Request lookupResult = null;
   
  @@ -336,7 +329,7 @@
           return lookupResult;
       }
   
  -    ServletWrapper getServletByName(String servletName) {
  +    public ServletWrapper getServletByName(String servletName) {
   	return (ServletWrapper)servlets.get(servletName);
       }
   
  @@ -394,46 +387,50 @@
   	servlets.put(name, wrapper);
       }
   
  -    private void removeServlets(ServletWrapper[] sw) {
  -	if (sw != null) {
  -	    for (int i = 0; i < sw.length; i++) {
  -	        if (prefixMappedServlets.contains(sw[i])) {
  -		    Enumeration enum = prefixMappedServlets.keys();
  -
  -		    while (enum.hasMoreElements()) {
  -		        String key = (String)enum.nextElement();
  -
  -			if (prefixMappedServlets.get(key).equals(sw[i])) {
  -			    prefixMappedServlets.remove(key);
  -			}
  -		    }
  +    private void removeServlet(ServletWrapper sw) {
  +	if (prefixMappedServlets.contains(sw)) {
  +	    Enumeration enum = prefixMappedServlets.keys();
  +	    
  +	    while (enum.hasMoreElements()) {
  +		String key = (String)enum.nextElement();
  +		
  +		if (prefixMappedServlets.get(key).equals(sw)) {
  +		    prefixMappedServlets.remove(key);
   		}
  -
  -		if (extensionMappedServlets.contains(sw[i])) {
  -		    Enumeration enum = extensionMappedServlets.keys();
  -
  -		    while (enum.hasMoreElements()) {
  -		        String key = (String)enum.nextElement();
  +	    }
  +	}
  +	
  +	if (extensionMappedServlets.contains(sw)) {
  +	    Enumeration enum = extensionMappedServlets.keys();
  +	    
  +	    while (enum.hasMoreElements()) {
  +		String key = (String)enum.nextElement();
   
  -			if (extensionMappedServlets.get(key).equals(sw[i])) {
  -			    extensionMappedServlets.remove(key);
  -			}
  -		    }
  +		if (extensionMappedServlets.get(key).equals(sw)) {
  +		    extensionMappedServlets.remove(key);
   		}
  -
  -		if (pathMappedServlets.contains(sw[i])) {
  -		    Enumeration enum = pathMappedServlets.keys();
  -
  -		    while (enum.hasMoreElements()) {
  -		        String key = (String)enum.nextElement();
  +	    }
  +	}
  +	
  +	if (pathMappedServlets.contains(sw)) {
  +	    Enumeration enum = pathMappedServlets.keys();
  +	    
  +	    while (enum.hasMoreElements()) {
  +		String key = (String)enum.nextElement();
   
  -			if (pathMappedServlets.get(key).equals(sw[i])) {
  -			    pathMappedServlets.remove(key);
  -			}
  -		    }
  +		if (pathMappedServlets.get(key).equals(sw)) {
  +		    pathMappedServlets.remove(key);
   		}
  -
  -	        servlets.remove(sw[i].getServletName());
  +	    }
  +	}
  +	
  +	servlets.remove(sw.getServletName());
  +    }
  +    
  +    private void removeServlets(ServletWrapper[] sw) {
  +	if (sw != null) {
  +	    for (int i = 0; i < sw.length; i++) {
  +		removeServlet( sw[i] );
   	    }
   	}
       }
  @@ -466,7 +463,7 @@
       // XXX
       // made package protected so that RequestMapper can have access
   
  -    ServletWrapper[] getServletsByPath(String path) {
  +    public ServletWrapper[] getServletsByPath(String path) {
           Vector servletWrappers = new Vector();
   	Enumeration enum = servlets.keys();
   
  
  
  
  1.13      +7 -60     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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Context.java	2000/01/07 18:48:34	1.12
  +++ Context.java	2000/01/07 19:14:10	1.13
  @@ -86,7 +86,7 @@
       private StringManager sm =
           StringManager.getManager(Constants.Package);
       private boolean initialized = false;
  -    private Server server;
  +    private ContextManager server;
       private String description = null;
       private boolean isDistributable = false;
       private String engineHeader = null;
  @@ -120,11 +120,11 @@
       private Vector destroyInterceptors = new Vector();
       private RequestSecurityProvider rsProvider =
           DefaultRequestSecurityProvider.getInstance();
  -
  +    
       public Context() {
       }
   	
  -    public Context(Server server, String path) {
  +    public Context(ContextManager server, String path) {
           this.server = server;
   	this.path = path;
   
  @@ -155,6 +155,10 @@
       public String getEngineHeader() {
           return engineHeader;
       }
  +
  +    public ContextManager getContextManager() {
  +	return server;
  +    }
       
       public String getPath() {
   	return path;
  @@ -597,63 +601,6 @@
   
       ServletContextFacade getFacade() {
           return contextFacade;
  -    }
  -
  -    public void handleRequest(Request request, Response response)
  -    throws IOException {
  -	// XXX
  -	// make sure we are init'd or throw an illegal state exception
  -
  -	request.setContext(this);
  -	request.setResponse(response);
  -	
  -	// look for session id -- cookies only right now
  -
  -	ServerSession session =
  -	    sessionManager.getServerSession(request, response, false);
  -
  -	if (session != null) {
  -	    session.accessed();
  -
  -	    ApplicationSession appSession =
  -	        session.getApplicationSession(this, false);
  -
  -	    if (appSession != null) {
  -	        appSession.accessed();
  -	    }
  -	}
  -
  -	request.setServerSession(session);  // may be null
  -
  -	// XXX XXX XXX lookupServlet should operate on the original
  -	// request, it will change when we introduce the interceptors.
  -	Request result =
  -	    container.lookupServlet(request.getLookupPath());
  -	
  -	request.setServletPath(result.getServletPath());
  -	request.setPathInfo(result.getPathInfo());
  -
  -        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 {
  -            request.removeAttribute(Constants.Attribute.RESOLVED_SERVLET);
  -        }
  -
  -	result.getWrapper().handleRequest(request.getFacade(),
  -            response.getFacade());
  -
  -	//ServletWrapper wrap = container.resolveServlet(request);
  -	
  -	// XXX
  -	// we want to be sure to handle any IOExceptions here
  -	// and log 'em -- also an UnavailableExceptions would be
  -	// trapped here.
  -	
  -	//wrap.handleRequest(request.getFacade(), response.getFacade());
       }
   
       private Properties getProperties(String propertyFileName) {
  
  
  
  1.5       +38 -57    jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContextManager.java	1999/10/28 05:15:24	1.4
  +++ ContextManager.java	2000/01/07 19:14:11	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v 1.4 1999/10/28 05:15:24 costin Exp $
  - * $Revision: 1.4 $
  - * $Date: 1999/10/28 05:15:24 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v 1.5 2000/01/07 19:14:11 costin Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/01/07 19:14:11 $
    *
    * ====================================================================
    *
  @@ -66,6 +66,7 @@
   
   import org.apache.tomcat.core.*;
   import org.apache.tomcat.net.*;
  +import org.apache.tomcat.request.*;
   import org.apache.tomcat.util.*;
   import java.io.*;
   import java.net.*;
  @@ -94,7 +95,11 @@
       private StringManager sm =
           StringManager.getManager(Constants.Package);
   
  -
  +    ContextInterceptor contextInterceptor=new ContextInterceptor( this );
  +    SessionInterceptor sessionInterceptor=new SessionInterceptor();
  +    MapperInterceptor mapperInterceptor=new MapperInterceptor();
  +    
  +    
       /**
        * The default Context used to process paths not associated with
        * any other Context.
  @@ -235,49 +240,11 @@
       public Context getContext(String name) {
   	return (Context)contexts.get(name);
       }
  -
  -
  -    /**
  -     * Gets the context that is responsible for requests for a
  -     * particular path.  If no specifically assigned Context can be
  -     * identified, returns the default Context.
  -     *
  -     * @param path The path for which a Context is requested
  -     */
  -    
  -    public Context getContextByPath(String path) {
  -	String realPath = path;
  -	Context ctx = null;
  -
  -	// XXX
  -	// needs help ... this needs to be optimized out.
  -
  -        lookup:
  -	do {
  -	    ctx = (Context)contextMaps.get(path);
  -	    if (ctx == null) {
  -	        int i = path.lastIndexOf('/');
  -		if (i > -1 && path.length() > 1) {
  -		    path = path.substring(0, i);
  -		    if (path.length() == 0) {
  -		        path = "/";
  -		    }
  -		} else {
  -		    // path too short
  -		    break lookup;
  -		}
  -	    } else {
  -	    }
  -	} while (ctx == null);
  -
  -	if (ctx == null) {
  -	    ctx = defaultContext;
  -	}
   
  -	return ctx;
  +    public Context getMappedContext( String path ) {
  +	return  (Context)contextMaps.get(path);
       }
   
  -
       /**
        * Adds a new Context to the set managed by this ContextManager.
        * XXX Why is there no context name argument?
  @@ -419,25 +386,24 @@
   		return;
   	    }
   
  -	    // resolve the server that we are for
  -	    String path = rrequest.getRequestURI();
  -	    
  -	    Context ctx= this.getContextByPath(path);
  -	    
  -	    // final fix on response & request
  -	    //		rresponse.setServerHeader(server.getServerHeader());
  -	    
  -	    String ctxPath = ctx.getPath();
  -	    String pathInfo =path.substring(ctxPath.length(),
  -					    path.length());
   	    //    don't do headers if request protocol is http/0.9
   	    if (rrequest.getProtocol() == null) {
   		rresponse.setOmitHeaders(true);
   	    }
  +
  +	    // XXX Hardcoded - it will be changed in the next step.( costin )
  +
  +	    // will set the Context
  +	    contextInterceptor.handleRequest( rrequest );
  +	    // will set Session 
  +	    sessionInterceptor.handleRequest( rrequest );
   	    
  +	    // will set all other fields and ServletWrapper
  +	    mapperInterceptor.handleRequest( rrequest );
  +
   	    // do it
  -	    //		System.out.println( request + " " + rresponse );
  -	    ctx.handleRequest(rrequest, rresponse);
  +	    rrequest.getWrapper().handleRequest(rrequest.getFacade(),
  +					       rresponse.getFacade());
   	    
   	    // finish and clean up
   	    rresponse.finish();
  @@ -453,5 +419,20 @@
   	}
       }
   
  +    // XXX need to be changed to use a full sub-request model (costin)
  +    
  +    /** Will find the ServletWrapper for a servlet, assuming we already have
  +     *  the Context. This is used by Dispatcher and getResource - where the Context
  +     *  is already known.
  +     */
  +    int internalRequestParsing( Request req ) {
  +	return mapperInterceptor.handleRequest( req );
  +    }
  +    
  +    public Context getContextByPath(String path ) {
  +	// XXX XXX XXX need to create a sub-request !!!!
  +	// 
  +	return contextInterceptor.getContextByPath( path );      
  +    }
       
   }
  
  
  
  1.4       +8 -7      jakarta-tomcat/src/share/org/apache/tomcat/core/HttpServletRequestFacade.java
  
  Index: HttpServletRequestFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/HttpServletRequestFacade.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HttpServletRequestFacade.java	1999/11/08 03:58:41	1.3
  +++ HttpServletRequestFacade.java	2000/01/07 19:14:11	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/HttpServletRequestFacade.java,v 1.3 1999/11/08 03:58:41 akv Exp $
  - * $Revision: 1.3 $
  - * $Date: 1999/11/08 03:58:41 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/HttpServletRequestFacade.java,v 1.4 2000/01/07 19:14:11 costin Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/01/07 19:14:11 $
    *
    * ====================================================================
    *
  @@ -259,16 +259,17 @@
       }
   
       public HttpSession getSession() {
  -        return request.getSession();
  +        return request.getSession(true);
       }
       
       public HttpSession getSession(boolean create) {
           return request.getSession(create);
       }
   
  -    public ServerSession getServerSession(boolean create) {
  -        return request.getServerSession(create);
  -    }
  +    // XXX XXX is it used ?? (costin)
  +    //     public ServerSession getServerSession(boolean create) {
  +    //         return request.getServerSession(create);
  +    //     }
   
       public BufferedReader getReader() throws IOException {
   	if (usingStream) {
  
  
  
  1.12      +66 -35    jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java
  
  Index: Request.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Request.java	2000/01/07 18:48:34	1.11
  +++ Request.java	2000/01/07 19:14:11	1.12
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v 1.11 2000/01/07 18:48:34 costin Exp $
  - * $Revision: 1.11 $
  - * $Date: 2000/01/07 18:48:34 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v 1.12 2000/01/07 19:14:11 costin Exp $
  + * $Revision: 1.12 $
  + * $Date: 2000/01/07 19:14:11 $
    *
    * ====================================================================
    *
  @@ -109,7 +109,7 @@
       protected HttpServletRequestFacade requestFacade;
       protected Context context;
       protected Hashtable attributes = new Hashtable();
  -    protected ServerSession serverSession;
  +    protected HttpSession serverSession;
   
       protected boolean didReadFormData;
       protected boolean didParameters;
  @@ -121,6 +121,7 @@
       ServletWrapper wrapper = null;
       String mappedPath = null;
       String resolvedServlet = null;
  +    String resouceName=null;
   
       protected StringManager sm =
           StringManager.getManager(Constants.Package);
  @@ -208,6 +209,9 @@
   	return lookupPath;
       }
   
  +    public void setLookupPath( String l ) {
  +	lookupPath=l;
  +    }
   
       public String[] getParameterValues(String name) {
   	if(!didParameters) {
  @@ -318,14 +322,24 @@
   	this.response = response;
       }
   
  -    // Called after a Context is found, adjust all other paths.
  -    // XXX XXX XXX
  +    public Response getResponse() {
  +	return response;
  +    }
  +    
       public void setContext(Context context) {
   	this.context = context;
  +    }
  +
  +    // Called after a Context is found, adjust all other paths.
  +    // XXX XXX XXX
  +    public void updatePaths() {
   	contextPath = context.getPath();
   	String requestURI = getRequestURI();
  -	lookupPath = requestURI.substring(contextPath.length(),
  -            requestURI.length());
  +	// do not set it if it is already set or we have no
  +	// URI - the case of a sub-request generated internally
  +	if( requestURI!=null && lookupPath==null ) 
  +	    lookupPath = requestURI.substring(contextPath.length(),
  +					      requestURI.length());
   
   	// check for ? string on lookuppath
   	int qindex = lookupPath.indexOf("?");
  @@ -360,36 +374,45 @@
       }
   
   
  -    public ApplicationSession getSession() {
  -        return getSession(true);
  -    }
  +//     // XXX XXX XXX
  +//     public ServerSession getServerSession(boolean create) {
  +// 	if (context == null) {
  +// 	    System.out.println("CONTEXT WAS NEVER SET");
  +// 	    return null;
  +// 	}
  +
  +// 	if (serverSession == null && create) {
  +//             serverSession =
  +// 		ServerSessionManager.getManager()
  +// 		    .getServerSession(this, response, create);
  +//             serverSession.accessed();
  +// 	}
   
  -    // XXX XXX XXX
  -    public ServerSession getServerSession(boolean create) {
  -	if (context == null) {
  -	    System.out.println("CONTEXT WAS NEVER SET");
  -	    return null;
  -	}
  +// 	return serverSession;
  +//     }
   
  -	if (serverSession == null && create) {
  -            serverSession =
  -		ServerSessionManager.getManager()
  -		    .getServerSession(this, response, create);
  -            serverSession.accessed();
  +    public HttpSession getSession(boolean create) {
  +	if( serverSession==null ) {
  +	    if( ! create )
  +		return null;
  +	    else {
  +// 		serverSession =
  +// 		    ServerSessionManager.getManager()
  +// 		    .getServerSession(this, response, create);
  +// 		serverSession.accessed();
  +		serverSession =ServerSessionManager.getManager()
  + 		    .getSession(this, response, create);
  + 		
  +	    }
   	}
   
  +	// assert serverSession!=null
  +// 	ApplicationSession appSession = null;
  +// 	return  serverSession.getApplicationSession(context, create);
   	return serverSession;
  -    }
  -
  -    public ApplicationSession getSession(boolean create) {
  -	getServerSession(create);
  -	ApplicationSession appSession = null;
  -	if (serverSession != null) {
  -	    appSession = serverSession.getApplicationSession(context, create);
  -	}
   
  -	return appSession;
   
  +	
   	//  if (reqSessionId != null) {
   //  	    //Session session = context.getSession(reqSessionId);
   //  	    //if (session == null) {
  @@ -408,30 +431,38 @@
       }
   
       // -------------------- LookupResult 
  -    String getResolvedServlet() {
  +    public String getResolvedServlet() {
   	return resolvedServlet;
       }
   
  -    void setResolvedServlet(String rs ) {
  +    public void setResolvedServlet(String rs ) {
   	resolvedServlet=rs;
       }
   
  -    ServletWrapper getWrapper() {
  +    public ServletWrapper getWrapper() {
   	return wrapper;
       }
       
  -    void setWrapper(ServletWrapper wrapper) {
  +    public void setWrapper(ServletWrapper wrapper) {
   	this.wrapper=wrapper;
       }
   
  -    String getMappedPath() {
  +    public String getMappedPath() {
   	return mappedPath;
       }
   
  -    void setMappedPath( String m ) {
  +    public void setMappedPath( String m ) {
   	mappedPath=m;
       }
   
  +    public String getResourceName() {
  +	return resouceName;
  +    }
  +
  +    public void setResourceName( String m ) {
  +	resouceName=m;
  +    }
  +
       // -------------------- Setters
   //     public void setURI(String requestURI) {
   //         this.requestURI = requestURI;
  @@ -566,7 +597,7 @@
   	this.reqSessionId = reqSessionId;
       }
   
  -    public void setServerSession(ServerSession serverSession) {
  +    public void setSession(HttpSession serverSession) {
   	this.serverSession = serverSession;
       }
   
  
  
  
  1.5       +5 -6      jakarta-tomcat/src/share/org/apache/tomcat/core/RequestDispatcherImpl.java
  
  Index: RequestDispatcherImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestDispatcherImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RequestDispatcherImpl.java	2000/01/07 18:48:34	1.4
  +++ RequestDispatcherImpl.java	2000/01/07 19:14:11	1.5
  @@ -1,8 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestDispatcherImpl.java,v 1.4 2000/01/07 18:48:34 costin Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/01/07 18:48:34 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -252,8 +248,11 @@
   	}
   
   	this.urlPath = urlPath;
  -	this.lookupResult =
  -	    context.getContainer().lookupServlet(this.urlPath);
  +
  +	this.lookupResult = new Request();
  +	lookupResult.setLookupPath( this.urlPath );
  +	lookupResult.setContext( context );
  +	context.getContextManager().internalRequestParsing(lookupResult);
       }
   
       boolean isValid() {
  
  
  
  1.5       +23 -4     jakarta-tomcat/src/share/org/apache/tomcat/core/ServerSessionManager.java
  
  Index: ServerSessionManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServerSessionManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ServerSessionManager.java	1999/11/01 20:50:47	1.4
  +++ ServerSessionManager.java	2000/01/07 19:14:11	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServerSessionManager.java,v 1.4 1999/11/01 20:50:47 costin Exp $
  - * $Revision: 1.4 $
  - * $Date: 1999/11/01 20:50:47 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServerSessionManager.java,v 1.5 2000/01/07 19:14:11 costin Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/01/07 19:14:11 $
    *
    * ====================================================================
    *
  @@ -87,7 +87,7 @@
   	manager = new ServerSessionManager();
       }
       
  -    static ServerSessionManager getManager() {
  +    public static ServerSessionManager getManager() {
   	return manager;
       }
   
  @@ -100,6 +100,25 @@
   	reaper.start();
       }
   
  +    /** Called from Request.getSession to create a new session 
  +     */
  +    public HttpSession getSession(Request request, Response response,
  +        boolean create) {
  +	ServerSession sSession=getServerSession( request, response, create);
  +	if( sSession!=null ) sSession.accessed();
  +	if( sSession ==null) return null;
  +	
  +	return sSession.getApplicationSession(request.getContext(), create);
  +    }
  +
  +    public void accessed( HttpSession session ) {
  +	ApplicationSession apS=(ApplicationSession)session;
  +	ServerSession servS=apS.getServerSession();
  +	servS.accessed();
  +	apS.accessed();
  +	
  +    }
  +    
       ServerSession getServerSession(Request request, Response response,
           boolean create) {
   	// Look for session id -- cookies only right now
  
  
  
  1.7       +8 -6      jakarta-tomcat/src/share/org/apache/tomcat/core/ServletContextFacade.java
  
  Index: ServletContextFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletContextFacade.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ServletContextFacade.java	2000/01/07 18:48:34	1.6
  +++ ServletContextFacade.java	2000/01/07 19:14:12	1.7
  @@ -1,8 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletContextFacade.java,v 1.6 2000/01/07 18:48:34 costin Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/01/07 18:48:34 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -249,9 +245,15 @@
   	// XXX
   	// this could use a once over - after war perhaps
   
  +
  +	
           URL docBase = context.getDocumentBase();
  -	Request lr =
  -	    getRealContext().getContainer().lookupServlet(path);
  +
  +	Request lr = new Request();
  +	lr.setLookupPath( path );
  +	lr.setContext( getRealContext() );
  +	getRealContext().getContextManager().internalRequestParsing(lr);
  +
   	String mappedPath = path;
   
   	if (lr != null &&
  
  
  
  1.6       +10 -9     jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java
  
  Index: ServletWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ServletWrapper.java	1999/11/01 20:50:48	1.5
  +++ ServletWrapper.java	2000/01/07 19:14:12	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java,v 1.5 1999/11/01 20:50:48 costin Exp $
  - * $Revision: 1.5 $
  - * $Date: 1999/11/01 20:50:48 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java,v 1.6 2000/01/07 19:14:12 costin Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/01/07 19:14:12 $
    *
    * ====================================================================
    *
  @@ -83,7 +83,7 @@
   // WARNING: Some of the APIs in this class are used by J2EE. 
   // Please talk to harishp@eng.sun.com before making any changes.
   //
  -class ServletWrapper {
  +public class ServletWrapper {
   
       private StringManager sm =
           StringManager.getManager(Constants.Package);
  @@ -110,7 +110,7 @@
   	isReloadable = reloadable;
       }
   
  -    String getServletName() {
  +    public String getServletName() {
           return config.getServletName();
       }
   
  @@ -126,11 +126,11 @@
           this.description = description;
       }
   
  -    String getPath() {
  +    public String getPath() {
           return this.path;
       }
   
  -    void setPath(String path) {
  +    public void setPath(String path) {
           this.path = path;
       }
   
  @@ -141,11 +141,11 @@
   	config.setServletClassName(this.servletClassFile.getName());
       }
   
  -    String getServletClass() {
  +    public String getServletClass() {
           return this.servletClassName;
       }
   
  -    void setServletClass(String servletClassName) {
  +    public void setServletClass(String servletClassName) {
           this.servletClassName = servletClassName;
   
   	config.setServletClassName(servletClassName);
  @@ -233,6 +233,7 @@
   				 Constants.JSP.Directive.Compile.Value );
   
               request.setContext(getContext());
  +	    request.updatePaths();
               request.getSession(true);
   
               RequestDispatcher rd =
  
  
  
  1.1                  jakarta-tomcat/src/share/org/apache/tomcat/core/RequestInterceptor.java
  
  Index: RequestInterceptor.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestInterceptor.java,v 1.1 2000/01/07 19:14:11 costin Exp $
   * $Revision: 1.1 $
   * $Date: 2000/01/07 19:14:11 $
   *
   * ====================================================================
   *
   * 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.core;
  import javax.servlet.Servlet;
  
  /**
   * For request processing - before calling service() ( or any LifecycleInterceptors )
   *
   * @author costin@dnt.ro
   */
  public interface RequestInterceptor {
      public static final int OK=0;
      
      public int handleRequest(Request request);
  }
  
  
  
  1.1                  jakarta-tomcat/src/share/org/apache/tomcat/request/ContextInterceptor.java
  
  Index: ContextInterceptor.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/ContextInterceptor.java,v 1.1 2000/01/07 19:14:15 costin Exp $
   * $Revision: 1.1 $
   * $Date: 2000/01/07 19:14:15 $
   *
   * ====================================================================
   *
   * 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.request;
  
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.net.*;
  import org.apache.tomcat.util.*;
  import java.io.*;
  import java.net.*;
  import java.util.*;
  
  
  public class ContextInterceptor implements RequestInterceptor {
      ContextManager cm;
      
      public ContextInterceptor(ContextManager cm) {
  	this.cm=cm;
      }
  
      public int handleRequest( Request rrequest ) {
  	// resolve the server that we are for
  	String path = rrequest.getRequestURI();
  	
  	Context ctx= this.getContextByPath(path);
  	
  	// final fix on response & request
  	//		rresponse.setServerHeader(server.getServerHeader());
  	
  	String ctxPath = ctx.getPath();
  	String pathInfo =path.substring(ctxPath.length(),
  					    path.length());
  	rrequest.setContext(ctx);
  	rrequest.updatePaths();
  	return OK;
      }
  
  
      // XXX XXX XXX need to fix this - it is used by getContext(String path) (costin)
      
      /**
       * Gets the context that is responsible for requests for a
       * particular path.  If no specifically assigned Context can be
       * identified, returns the default Context.
       *
       * @param path The path for which a Context is requested
       */
      public Context getContextByPath(String path) {
  	String realPath = path;
  	Context ctx = null;
  
  	// XXX
  	// needs help ... this needs to be optimized out.
  
          lookup:
  	do {
  	    ctx = cm.getMappedContext(path);
  	    if (ctx == null) {
  	        int i = path.lastIndexOf('/');
  		if (i > -1 && path.length() > 1) {
  		    path = path.substring(0, i);
  		    if (path.length() == 0) {
  		        path = "/";
  		    }
  		} else {
  		    // path too short
  		    break lookup;
  		}
  	    } else {
  	    }
  	} while (ctx == null);
  
  	if (ctx == null) {
  	    ctx = cm.getDefaultContext();
  	}
  
  	return ctx;
      }
  
      
  }
  
  
  
  1.1                  jakarta-tomcat/src/share/org/apache/tomcat/request/MapperInterceptor.java
  
  Index: MapperInterceptor.java
  ===================================================================
  /*
   * ====================================================================
   *
   * 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.request;
  
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.core.Constants;
  import org.apache.tomcat.util.*;
  import java.util.Hashtable;
  
  // Based on RequestMapper.
  
  /**
   * Process the URI, find the Wrapper ( the Servlet that will handle the request) 
   * and set all Paths.
   * 
   * This is the original parser from Tomcat - please don't change it, but
   * create new interceptors ( we need to split it in more specialized
   * modules - and better parsers )
   *
   */
  public class MapperInterceptor  implements  RequestInterceptor {
  
      public MapperInterceptor() {
      }
  
      // no configuration 
      
      public int handleRequest(Request req) {
  	Container container=req.getContext().getContainer();
  	String path=req.getLookupPath();
          ServletWrapper wrapper = null;
  
  	wrapper = getMatch(container, path, req);
  
  	if (wrapper == null) {
  	    wrapper = container.getDefaultServlet();
  	    if (wrapper == null) {
  	        wrapper = container.getServletByName(Constants.Servlet.Default.Name);
  	    }
  
  	    String servletPath = Constants.Servlet.Default.Map;
              String pathInfo = path;
  
  	    req.setWrapper( wrapper );
  	    req.setServletPath( servletPath );
  	    req.setPathInfo( pathInfo );
  	} else {
  	    getMapPath(wrapper, req);
  	    String resolvedServlet = getResolvedServlet(container, req.getMappedPath());
  	    
  	    req.setWrapper( wrapper );
  	    req.setResolvedServlet( resolvedServlet );
  	}
  	
  	if (req.getResolvedServlet() != null) {
  	    req.setAttribute(Constants.Attribute.RESOLVED_SERVLET,
  				 req.getResolvedServlet());
  	} else if (req.getMappedPath() != null) {
  	    req.setAttribute(Constants.Attribute.RESOLVED_SERVLET,
  				 req.getMappedPath());
  	} else {
  	    req.removeAttribute(Constants.Attribute.RESOLVED_SERVLET);
  	}
  
  	return OK;
      }
  
      private ServletWrapper getMatch(Container container, String path, Request req) {
          ServletWrapper wrapper = null;
  	// try an exact match
  
          wrapper = getPathMatch(container, path, req);
  
  	// try a prefix match
  
  	if (wrapper == null) {
  	    wrapper = getPrefixMatch(container, path, req);
  	}
  
  	// try an extension match
  
  	if (wrapper == null) {
  	    wrapper = getExtensionMatch(container, path, req);
  	}
  
  	// lookup real servlet if what we're actually
  	// dealing with a jsp file
  
          wrapper = getServletForJsp(container, wrapper, req);
  
  	return wrapper;
      }
  
      private ServletWrapper getPathMatch(Container container, String path, Request req) {
          ServletWrapper wrapper = null;
  
  	wrapper = (ServletWrapper)container.getPathMap().get(path);
  
  	if (wrapper != null) {
  	    req.setServletPath( path );
  	    // this.servletPath = path;
  	}
  
          return wrapper;
      }
  
      private ServletWrapper getPrefixMatch(Container container, String path, Request req) {
  	ServletWrapper wrapper = null;
          String s = path;
  
  	while (s.length() > 0) {
  	    String suffix = (s.endsWith("/")) ? "*" : "/*";
   
  	    wrapper = (ServletWrapper)container.getPrefixMap().get(s + suffix);
  
  	    if (wrapper != null) {
  	        if (s.endsWith("/")) {
                      String t = s.substring(0, s.length() - 1);
  
  		    req.setServletPath( (t.trim().length() == 0) ? null : t );
  		    t = s.substring(s.length() - 1);
  		    req.setPathInfo(  (t.trim().length() == 0) ? null : t);
  		} else {
                      String t = s;
  
  		    req.setServletPath(  (t.trim().length() == 0) ? null : t);
                      t = path.substring(s.length(), path.length());
  		    req.setPathInfo((t.trim().length() == 0) ? null : t);
  		}
  
  		s = "";
  	    } else {
  	        int i = s.lastIndexOf("/");
  
                  if (i > 0) {
  		    s = s.substring(0, i);
                  } else if (i == 0 &&
                      ! s.equals("/")) {
                      s = "/";
                  } else {
                      s = "";
                  }
              }
  	}
  
  	return wrapper;
      }
  
      private ServletWrapper getExtensionMatch(Container container, String path, Request req) {
          ServletWrapper wrapper = null;
          int i = path.lastIndexOf(".");
  	int j = path.lastIndexOf("/");
  
  	if (i > -1) {
  	    String extension = path.substring(i);
  
  
  	    if (j > i) {
  	        int k = extension.indexOf("/");
  
  		extension = extension.substring(0, k);
  	    }
  
  	    wrapper = (ServletWrapper)container.getExtensionMap().get(
  	        "*" + extension);
  
  	    if (wrapper != null) {
  	        req.setServletPath( path );
  
  		if (j > i) {
  		    int k = i + path.substring(i).indexOf("/");
                      String s = path.substring(0, k);
  
  		    req.setServletPath( (s.trim().length() == 0) ? null : s );
                      s = path.substring(k);
  		    req.setPathInfo( (s.trim().length() == 0) ? null : s );
  		}
  	    }
  	}
  
  	return wrapper;
      }
  
      // XXX XXX XXX eliminate recursivity (costin )
      private ServletWrapper getServletForJsp(Container container, ServletWrapper wrapper, Request req) {
          if (wrapper != null) {
              String servletPath = req.getServletPath();
              String pathInfo = req.getPathInfo();
              req.setResourceName( req.getServletPath());
  
              boolean stillSearching = true;
              int counter = 0;
  
  
              while (stillSearching) {
                  if (wrapper != null &&
                      wrapper.getPath() != null &&
                      wrapper.getServletClass() == null) {
                          req.setResourceName( wrapper.getPath() );
                          wrapper = getMatch(container,
  					   wrapper.getPath() + (pathInfo == null ? "" : pathInfo),
  					   req);
                          req.setMappedPath(  req.getServletPath() );
  
                          if (stillSearching &&
                              ++counter > Constants.RequestURIMatchRecursion) {
                              stillSearching = false;
                          }
                  } else {
                      stillSearching = false;
                  }
              }
  
              req.setServletPath( servletPath);
              req.setPathInfo(pathInfo);
          }
  
          return wrapper;
      }
  
      private void getMapPath(ServletWrapper wrapper, Request req) {
          String mapPath = req.getMappedPath();
  
          // XXX
          // this is added to make available the destination
          // resource be it a servlet or jsp file - could be
          // cleaned up a bit (wobbly)
          if (req.getServletPath().equals(Constants.Servlet.Invoker.Map) &&
              req.getPathInfo() != null) {
              String s = req.getPathInfo();
  
              if (req.getPathInfo().startsWith("/")) {
                  s = req.getPathInfo().substring(1);
              }
  
              int i = s.indexOf("/");
  
              if (i > -1) {
                  s = s.substring(0, i);
              }
  
              mapPath = "/" + s;
          } else if (mapPath == null &&
              req.getResourceName() != null) {
              mapPath = req.getResourceName();
          }
  
          req.setMappedPath( mapPath );
      }
  
      private String getResolvedServlet(Container container, String path) {
          String resolvedServlet = null;
          ServletWrapper[] sw = container.getServletsByPath(path);
  
          if (sw.length > 0) {
              // assume one
              resolvedServlet = sw[0].getServletName();
          }
  
          return resolvedServlet;
      }
  }
  
  
  
  1.1                  jakarta-tomcat/src/share/org/apache/tomcat/request/SessionInterceptor.java
  
  Index: SessionInterceptor.java
  ===================================================================
  /*
   * ====================================================================
   *
   * 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.request;
  
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.util.*;
  import org.apache.tomcat.deployment.*;
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import javax.servlet.http.*;
  
  /**
   * 
   */
  public class SessionInterceptor implements RequestInterceptor {
      
      private ServerSessionManager sessionManager = ServerSessionManager.getManager();
  
      public SessionInterceptor() {
      }
  	
      public int handleRequest(Request request ) {
  	// look for session id -- cookies only right now
  
  	HttpSession session= sessionManager.getSession(request, request.getResponse(), false);
  
  	// ServerSession session =
  	// 	    sessionManager.getServerSession(request, request.getResponse(), false);
  
  	if (session != null) {
  	    sessionManager.accessed( session );
  	}
  
  	request.setSession(session);  // may be null
  	return 0;
      }
  }
  
  
  
  1.7       +5 -17     jakarta-tomcat/src/share/org/apache/tomcat/server/ConnectionHandler.java
  
  Index: ConnectionHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/server/ConnectionHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ConnectionHandler.java	1999/10/31 19:28:06	1.6
  +++ ConnectionHandler.java	2000/01/07 19:14:15	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/server/ConnectionHandler.java,v 1.6 1999/10/31 19:28:06 costin Exp $
  - * $Revision: 1.6 $
  - * $Date: 1999/10/31 19:28:06 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/server/ConnectionHandler.java,v 1.7 2000/01/07 19:14:15 costin Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/01/07 19:14:15 $
    *
    * ====================================================================
    *
  @@ -194,22 +194,10 @@
   		}
   
   		HttpServer server = manager.resolveServer(endpoint,hostHeader);
  -		String path = request.getRequestURI();
  -		int index = path.indexOf("?");
  -
   		response.setServerHeader(server.getServerHeader());
  -
  -		if (index > 0 ) {
  -		    path = path.substring(0, index);
  -		}
   
  -		Context ctx = server.getContextByPath(path);
  -		String ctxPath = ctx.getPath();
  -		String pathInfo =
  -		    path.substring(ctxPath.length(), path.length());
  -		
  -		ctx.handleRequest(request, response);
  -		response.finish();
  +		ContextManager cm=server.getContextManager();
  +		cm.service( request, response );
   
   		request.recycle();
   		response.recycle();
  
  
  
  1.7       +4 -36     jakarta-tomcat/src/share/org/apache/tomcat/service/Ajp22ConnectionHandler.java
  
  Index: Ajp22ConnectionHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/Ajp22ConnectionHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Ajp22ConnectionHandler.java	1999/11/02 17:37:20	1.6
  +++ Ajp22ConnectionHandler.java	2000/01/07 19:14:16	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/Ajp22ConnectionHandler.java,v 1.6 1999/11/02 17:37:20 costin Exp $
  - * $Revision: 1.6 $
  - * $Date: 1999/11/02 17:37:20 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/Ajp22ConnectionHandler.java,v 1.7 2000/01/07 19:14:16 costin Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/01/07 19:14:16 $
    *
    * ====================================================================
    *
  @@ -130,39 +130,7 @@
   		    break;
   		}
   
  -		// XXX
  -                //    return if an error was detected in processing the
  -                //    request line
  -		if (rresponse.getStatus() >= 400) {
  -		    rresponse.finish();
  -		    rrequest.recycle();
  -		    rresponse.recycle();
  -		    break;
  -		}
  -
  -		
  -		// resolve the server that we are for
  -		String path = rrequest.getRequestURI();
  -	
  -		Context ctx= contextM.getContextByPath(path);
  -
  -		// final fix on response & request
  -		//		rresponse.setServerHeader(server.getServerHeader());
  -
  -                //    don't do headers if request protocol is http/0.9
  -		if (rrequest.getProtocol() == null) {
  -		    rresponse.setOmitHeaders(true);
  -		}
  -
  -		// do it
  -		//		System.out.println( request + " " + rresponse );
  -		ctx.handleRequest(rrequest, rresponse);
  -
  -		// finish and clean up
  -		rresponse.finish();
  -
  -		// protocol notification
  -		msg.endResponse();
  +		contextM.service(rrequest, rresponse);
   		
   		rrequest.recycle();
   		rresponse.recycle();
  
  
  

Mime
View raw message