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-4.0/catalina/src/share/org/apache/catalina/servlets DefaultServlet.java
Date Tue, 10 Oct 2000 02:17:34 GMT
remm        00/10/09 19:17:34

  Modified:    catalina/src/share/org/apache/catalina/servlets
                        DefaultServlet.java
  Log:
  - A redirect is sent back if a welcome file is found. That way, the request will
    go through all the pipeline, and security contraints will be enforced.
    Reported by Paul Lamb <paul@oil-law.com>
  - Minor cleanup.
  
  Revision  Changes    Path
  1.9       +16 -28    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java
  
  Index: DefaultServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultServlet.java	2000/10/06 00:47:17	1.8
  +++ DefaultServlet.java	2000/10/10 02:17:33	1.9
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
1.8 2000/10/06 00:47:17 craigmcc Exp $
  - * $Revision: 1.8 $
  - * $Date: 2000/10/06 00:47:17 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
1.9 2000/10/10 02:17:33 remm Exp $
  + * $Revision: 1.9 $
  + * $Date: 2000/10/10 02:17:33 $
    *
    * ====================================================================
    *
  @@ -112,7 +112,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.8 $ $Date: 2000/10/06 00:47:17 $
  + * @version $Revision: 1.9 $ $Date: 2000/10/10 02:17:33 $
    */
   
   public class DefaultServlet
  @@ -1207,26 +1207,15 @@
   	    return;
   	}
   
  -        // Retrieve the Catalina context
  +        // Retrieve the Catalina context and Resources implementation
           ApplicationContext context = (ApplicationContext) getServletContext();
  +        Resources resources = context.getResources();
  +        ResourceInfo resourceInfo = new ResourceInfo(path, resources);
   
  -	// Convert the resource path to a URL
  -	URL resourceURL = null;
  -	try {
  -	    resourceURL = context.getResource(path);
  -	} catch (MalformedURLException e) {
  -	    ;
  -	}
  -	if (resourceURL == null) {
  +        if (!resourceInfo.exists) {
   	    response.sendError(HttpServletResponse.SC_NOT_FOUND, path);
   	    return;
  -	}
  -	if (debug > 0)
  -	    log("DefaultServlet.serveResource:  Corresponding URL is '" +
  -		resourceURL.toString() + "'");
  -        
  -        Resources resources = context.getResources();
  -        ResourceInfo resourceInfo = new ResourceInfo(path, resources);
  +        }
   
           // If the resource is a collection (aka a directory), we check 
           // the welcome files list.
  @@ -1239,14 +1228,13 @@
   
               ResourceInfo welcomeFileInfo = checkWelcomeFiles(path, resources);
               if (welcomeFileInfo != null) {
  -                resourceInfo = welcomeFileInfo;
  -		RequestDispatcher rd =
  -		  getServletContext().getRequestDispatcher
  -		    (resourceInfo.path);
  -		if (rd != null) {
  -		    rd.forward(request, response);
  -		    return;
  -		}
  +                String redirectPath = welcomeFileInfo.path;
  +                String contextPath = request.getContextPath();
  +                if ((contextPath != null) && (!contextPath.equals("/"))) {
  +                    redirectPath = contextPath + redirectPath;
  +                }
  +                response.sendRedirect(redirectPath);
  +                return;
               }
               
           }
  
  
  

Mime
View raw message