From: <ska...@us...> - 2002-12-27 23:36:41
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv15635/src/org/webmacro/servlet Modified Files: Servlet22Broker.java Log Message: fixed issues with loading resources from classpath that start with a slash. Was already fixed in v1_0 branch but somehow did not get into into HEAD Index: Servlet22Broker.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/Servlet22Broker.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Servlet22Broker.java 11 Jun 2002 17:43:22 -0000 1.9 --- Servlet22Broker.java 27 Dec 2002 23:36:37 -0000 1.10 *************** *** 132,147 **** public URL getResource(String name) { try { ! // NOTE: Tomcat4 needs a leading '/'. ! // If this doesn't work with your 2.2+ container, try commenting out the following line ! if (!name.startsWith("/")) name = "/" + name; ! URL u = _servletContext.getResource(name); if (u != null && u.getProtocol().equals("file")) { ! File f = new File(u.getFile()); ! if (!f.exists()) ! u = null; } ! if (u == null) u = _servletClassLoader.getResource(name); ! if (u == null) u = super.getResource(name); return u; --- 132,158 ---- public URL getResource(String name) { try { ! // NOTE: Tomcat4 needs a leading '/'. ! // However, when loading resources from the class-loader, they ! // may _not_ start with a leading '/'. So we have to build ! // up two different names. Ugly! ! String contextName = name; ! if (name.startsWith("/")) { ! name = name.substring(1); ! } else { ! StringBuffer b = new StringBuffer(name.length()+1); ! b.append("/"); ! b.append(name); ! contextName = b.toString(); ! } ! URL u = _servletContext.getResource(contextName); if (u != null && u.getProtocol().equals("file")) { ! File f = new File(u.getFile()); ! if (!f.exists()) ! u = null; } ! if (u == null) { u = _servletClassLoader.getResource(name); ! } ! if (u == null) u = super.getResource(name); return u; |