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 Sat, 05 Aug 2000 03:28:48 GMT
remm        00/08/04 20:28:48

  Modified:    proposals/catalina/src/share/org/apache/tomcat/servlets
                        DefaultServlet.java
  Log:
  - Fixes directory browser problems.
    A request on http://localhost:8080/examples/jsp wouldn't
    show the welcome page. A redirect to "/examples/jsp/" is
    now sent back to the client, if a welcome page exists for the
    directory.
  
  Revision  Changes    Path
  1.19      +28 -20    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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- DefaultServlet.java	2000/08/05 02:29:35	1.18
  +++ DefaultServlet.java	2000/08/05 03:28:47	1.19
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v
1.18 2000/08/05 02:29:35 remm Exp $
  - * $Revision: 1.18 $
  - * $Date: 2000/08/05 02:29:35 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v
1.19 2000/08/05 03:28:47 remm Exp $
  + * $Revision: 1.19 $
  + * $Date: 2000/08/05 03:28:47 $
    *
    * ====================================================================
    *
  @@ -108,7 +108,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.18 $ $Date: 2000/08/05 02:29:35 $
  + * @version $Revision: 1.19 $ $Date: 2000/08/05 03:28:47 $
    */
   
   public class DefaultServlet
  @@ -769,20 +769,21 @@
       private ResourceInfo checkWelcomeFiles(String pathname, 
                                              Resources resources) {
           
  -        if (pathname.endsWith("/")) {
  +        String collectionName = pathname;
  +        if (!pathname.endsWith("/")) {
  +            collectionName += "/";
  +        }
               
  -            // Serve a welcome resource or file if one exists
  -            // FIXME - update the welcome files list?
  -            for (int i = 0; i < welcomes.length; i++) {
  -                
  -                // Does the specified resource exist?
  -                String resourceName = pathname + welcomes[i];
  -                ResourceInfo resourceInfo = 
  -                    new ResourceInfo(resourceName, resources);
  -                if (resourceInfo.exists()) {
  -                    return resourceInfo;
  -                }
  -                
  +        // Serve a welcome resource or file if one exists
  +        // FIXME - update the welcome files list?
  +        for (int i = 0; i < welcomes.length; i++) {
  +            
  +            // Does the specified resource exist?
  +            String resourceName = collectionName + welcomes[i];
  +            ResourceInfo resourceInfo = 
  +                new ResourceInfo(resourceName, resources);
  +            if (resourceInfo.exists()) {
  +                return resourceInfo;
               }
               
           }
  @@ -849,7 +850,7 @@
   	if (debug > 0)
   	    log("DefaultServlet.serveResource:  Corresponding URL is '" +
   		resourceURL.toString() + "'");
  -
  +        
           Resources resources = context.getResources();
           ResourceInfo resourceInfo = new ResourceInfo(servletPath, resources);
   
  @@ -861,9 +862,16 @@
               if (welcomeFileInfo != null) {
                   resourceInfo = welcomeFileInfo;
               }
  +            
  +            if ((welcomeFileInfo != null) && 
  +                (!servletPath.endsWith("/"))) {
  +                response.sendRedirect(request.getRequestURI() + "/");
  +                return;
  +            }
  +            
           }
  -
  -	if (resourceInfo == null) {
  +        
  +	if (!resourceInfo.exists()) {
   	    response.sendError(HttpServletResponse.SC_NOT_FOUND, servletPath);
   	    return;
   	}
  
  
  

Mime
View raw message