tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@locus.apache.org
Subject cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets DefaultServlet.java
Date Tue, 01 Aug 2000 02:41:39 GMT
remm        00/07/31 19:41:37

  Modified:    proposals/catalina/src/share/org/apache/tomcat/resources
                        DirectoryBean.java FileResources.java
                        ResourcesBase.java
               proposals/catalina/src/share/org/apache/tomcat/servlets
                        DefaultServlet.java
  Log:
  - Minor cleanup
  - URL rewriting : " " <-> "%20"
  
  Revision  Changes    Path
  1.4       +30 -7     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/DirectoryBean.java
  
  Index: DirectoryBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/DirectoryBean.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DirectoryBean.java	2000/07/31 01:26:21	1.3
  +++ DirectoryBean.java	2000/08/01 02:41:21	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/DirectoryBean.java,v
1.3 2000/07/31 01:26:21 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/07/31 01:26:21 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/DirectoryBean.java,v
1.4 2000/08/01 02:41:21 remm Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/08/01 02:41:21 $
    *
    * ====================================================================
    *
  @@ -91,7 +91,7 @@
    * manner.  No internal synchronization is performed.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2000/07/31 01:26:21 $
  + * @version $Revision: 1.4 $ $Date: 2000/08/01 02:41:21 $
    */
   
   public final class DirectoryBean extends ResourceBean {
  @@ -265,7 +265,7 @@
   	    String parent = name.substring(0, slash);
   	    writer.print("<tr><td colspan=\"3\" bgcolor=\"#ffffff\">\r\n");
   	    writer.print("<a href=\"");
  -	    writer.print(contextPath);
  +	    writer.print(rewriteUrl(contextPath));
               if (parent.equals(""))
                   parent = "/";
   	    writer.print(parent);
  @@ -306,8 +306,8 @@
   
   	    writer.print("<td align=\"left\">&nbsp;&nbsp;\r\n");
   	    writer.print("<a href=\"");
  -	    writer.print(contextPath);
  -	    writer.print(resources[i].getName());
  +	    writer.print(rewriteUrl(contextPath));
  +	    writer.print(rewriteUrl(resources[i].getName()));
   	    writer.print("\"><tt>");
   	    writer.print(trimmed);
   	    if (resources[i] instanceof DirectoryBean)
  @@ -372,6 +372,29 @@
   
   	return ("" + leftSide + "." + rightSide + " kb");
   
  +    }
  +
  +
  +    /**
  +     * URL rewriter.
  +     * 
  +     * @param path Path which has to be rewiten
  +     */
  +    private String rewriteUrl(String path) {
  +        
  +        String normalized = path;
  +        
  +	// Replace " " with "%20"
  +	while (true) {
  +	    int index = normalized.indexOf(" ");
  +	    if (index < 0)
  +		break;
  +	    normalized = normalized.substring(0, index) + "%20"
  +		+ normalized.substring(index + 1);
  +	}
  +
  +        return normalized;
  +        
       }
   
   
  
  
  
  1.5       +4 -61     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/FileResources.java
  
  Index: FileResources.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/FileResources.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FileResources.java	2000/07/31 06:27:59	1.4
  +++ FileResources.java	2000/08/01 02:41:22	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/FileResources.java,v
1.4 2000/07/31 06:27:59 remm Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/07/31 06:27:59 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/FileResources.java,v
1.5 2000/08/01 02:41:22 remm Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/08/01 02:41:22 $
    *
    * ====================================================================
    *
  @@ -89,7 +89,7 @@
    * since they were cached.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2000/07/31 06:27:59 $
  + * @version $Revision: 1.5 $ $Date: 2000/08/01 02:41:22 $
    */
   
   public final class FileResources extends ResourcesBase {
  @@ -200,63 +200,6 @@
   	return (new URL("file://" + pathname));
   
       }
  -
  -
  -    /**
  -     * Get the ResourceBean object associated with the given path.
  -     *
  -     * @param path The path to the desired resource
  -     */
  -    /*
  -    public ResourceBean getResourceBean(String path) {
  -        
  -	validate(path);
  -
  -	// Look up the cached resource entry (if it exists) for this path
  -	String normalized = normalize(path);
  -	if (normalized == null)
  -	    return (null);
  -	ResourceBean resource = null;
  -	synchronized (resourcesCache) {
  -	    resource = (ResourceBean) resourcesCache.get(normalized);
  -	}
  -	if (resource != null)
  -	    return (resource);
  -        
  -	// Create a File object referencing the requested resource
  -	File file = file(normalized);
  -	if ((file == null) || !file.exists() || !file.canRead())
  -	    return (null);
  -
  -	// Special handling for directories
  -	if (file.isDirectory()) {
  -	    String contextPath =
  -		((Context) container).getPath();
  -	    if (contextPath == null)
  -		contextPath = "";
  -	    DirectoryBean directory = new DirectoryBean(normalized, file);
  -	    ;	// FIXME - Populate it with ResourceBean entries
  -	    return (directory.render(contextPath));
  -	}
  -
  -	// Cache the data for this resource (if appropriate and not yet done)
  -	if (cacheable(normalized, file.length())) {
  -	    resource = new ResourceBean(normalized, file);
  -	    try {
  -		resource.cache(inputStream(resource.getName()));
  -	    } catch (IOException e) {
  -		log(sm.getString("resources.input", resource.getName()), e);
  -		return (null);
  -	    }
  -	    synchronized (resourcesCache) {
  -		resourcesCache.put(resource.getName(), resource);
  -		resourcesCount++;
  -	    }
  -	    return (new ByteArrayInputStream(resource.getData()));
  -	}
  -        
  -    }
  -    */
   
   
       /**
  
  
  
  1.3       +13 -12    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/ResourcesBase.java
  
  Index: ResourcesBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/ResourcesBase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResourcesBase.java	2000/07/30 23:20:23	1.2
  +++ ResourcesBase.java	2000/08/01 02:41:23	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/ResourcesBase.java,v
1.2 2000/07/30 23:20:23 remm Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/07/30 23:20:23 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/ResourcesBase.java,v
1.3 2000/08/01 02:41:23 remm Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/08/01 02:41:23 $
    *
    * ====================================================================
    *
  @@ -101,7 +101,7 @@
    * (such as a local or remote JAR file).
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/07/30 23:20:23 $
  + * @version $Revision: 1.3 $ $Date: 2000/08/01 02:41:23 $
    */
   
   public abstract class ResourcesBase
  @@ -593,14 +593,6 @@
   
   
       /**
  -     * Get the ResourceBean object associated with the given path.
  -     *
  -     * @param path The path to the desired resource
  -     */
  -    //public abstract ResourceBean getResourceBean(String path);
  -
  -
  -    /**
        * Return the resource located at the named path as an
        * <code>InputStream</code> object.
        * <p>
  @@ -974,6 +966,15 @@
   	    normalized = normalized.substring(0, index) +
   		normalized.substring(index + 1);
   	}
  +
  +	// Resolve occurrences of "%20" in the normalized path
  +	while (true) {
  +	    int index = normalized.indexOf("%20");
  +	    if (index < 0)
  +		break;
  +	    normalized = normalized.substring(0, index) + " " +
  +		normalized.substring(index + 3);
  +        }
   
   	// Resolve occurrences of "/./" in the normalized path
   	while (true) {
  
  
  
  1.16      +4 -5      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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DefaultServlet.java	2000/07/31 06:28:00	1.15
  +++ DefaultServlet.java	2000/08/01 02:41:33	1.16
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v
1.15 2000/07/31 06:28:00 remm Exp $
  - * $Revision: 1.15 $
  - * $Date: 2000/07/31 06:28:00 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v
1.16 2000/08/01 02:41:33 remm Exp $
  + * $Revision: 1.16 $
  + * $Date: 2000/08/01 02:41:33 $
    *
    * ====================================================================
    *
  @@ -108,7 +108,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.15 $ $Date: 2000/07/31 06:28:00 $
  + * @version $Revision: 1.16 $ $Date: 2000/08/01 02:41:33 $
    */
   
   public class DefaultServlet
  @@ -883,7 +883,6 @@
               if (!listings) {
                   response.sendError(HttpServletResponse.SC_NOT_FOUND,
                                      servletPath);
  -                System.out.println("No listings ...");
                   return;
               }
               contentType = "text/html";
  
  
  

Mime
View raw message