Index: DefaultServlet.java =================================================================== RCS file: /cvs/glassfish/appserv-webtier/src/java/org/apache/catalina/servlets/DefaultServlet.java,v retrieving revision 1.17 diff -u -r1.17 DefaultServlet.java --- DefaultServlet.java 19 Jun 2007 16:45:19 -0000 1.17 +++ DefaultServlet.java 31 Aug 2007 22:52:54 -0000 @@ -699,12 +699,12 @@ } CacheEntry cacheEntry = null; + AlternateDocBase match = null; if (alternateDocBases == null || alternateDocBases.size() == 0) { cacheEntry = resources.lookupCache(path); } else { - AlternateDocBase match = AlternateDocBase.findMatch( - path, alternateDocBases); + match = AlternateDocBase.findMatch(path, alternateDocBases); if (match != null) { cacheEntry = match.getResources().lookupCache(path); } else { @@ -879,7 +879,7 @@ if (content) { // Serve the directory browser renderResult = - render(request.getContextPath(), cacheEntry); + render(request.getContextPath(), cacheEntry, match); } } @@ -1173,15 +1173,16 @@ /** * Decide which way to render. HTML or XML. */ - protected InputStream render - (String contextPath, CacheEntry cacheEntry) { + protected InputStream render(String contextPath, CacheEntry cacheEntry, + AlternateDocBase match) { + InputStream xsltInputStream = findXsltInputStream(cacheEntry.context); if (xsltInputStream==null) { - return renderHtml(contextPath, cacheEntry); + return renderHtml(contextPath, cacheEntry, match); } else { - return renderXml(contextPath, cacheEntry, xsltInputStream); + return renderXml(contextPath, cacheEntry, match, xsltInputStream); } } @@ -1195,8 +1196,16 @@ */ protected InputStream renderXml(String contextPath, CacheEntry cacheEntry, + AlternateDocBase match, InputStream xsltInputStream) { + ProxyDirContext renderResources = null; + if (match != null) { + renderResources = match.getResources(); + } else { + renderResources = resources; + } + StringBuffer sb = new StringBuffer(); sb.append(""); @@ -1215,7 +1224,7 @@ try { // Render the directory entries within this directory - NamingEnumeration enumeration = resources.list(cacheEntry.name); + NamingEnumeration enumeration = renderResources.list(cacheEntry.name); // rewriteUrl(contextPath) is expensive. cache result for later reuse String rewrittenContextPath = rewriteUrl(contextPath); @@ -1231,7 +1240,8 @@ continue; CacheEntry childCacheEntry = - resources.lookupCache(cacheEntry.name + resourceName); + renderResources.lookupCache(cacheEntry.name + + resourceName); if (!childCacheEntry.exists) { continue; } @@ -1295,7 +1305,7 @@ return (new ByteArrayInputStream(stream.toByteArray())); } catch (Exception e) { log("directory transform failure: " + e.getMessage()); - return renderHtml(contextPath, cacheEntry); + return renderHtml(contextPath, cacheEntry, match); } } @@ -1307,7 +1317,14 @@ * relative */ protected InputStream renderHtml - (String contextPath, CacheEntry cacheEntry) { + (String contextPath, CacheEntry cacheEntry, AlternateDocBase match) { + + ProxyDirContext renderResources = null; + if (match != null) { + renderResources = match.getResources(); + } else { + renderResources = resources; + } String name = cacheEntry.name; @@ -1393,7 +1410,7 @@ try { // Render the directory entries within this directory - NamingEnumeration enumeration = resources.list(cacheEntry.name); + NamingEnumeration enumeration = renderResources.list(cacheEntry.name); boolean shade = false; while (enumeration.hasMoreElements()) { @@ -1405,7 +1422,8 @@ continue; CacheEntry childCacheEntry = - resources.lookupCache(cacheEntry.name + resourceName); + renderResources.lookupCache(cacheEntry.name + + resourceName); if (!childCacheEntry.exists) { continue; }