final private InputStream getResourceForward( String name) { InputStream is = handler.servletClassLoader.getResourceAsStream( name); if (is != null) return is; return parent.getResourceAsStream(name); } public synchronized InputStream getResourceAsStream(String name) { String unslashedName = name; InputStream is = null; if (name.startsWith("/")) unslashedName = name.substring(1); byte[] buf = null; if (resources != null) buf = (byte[])resources.get(unslashedName); if (buf != null) return new ByteArrayInputStream(buf); ByteArrayOutputStream baos = new ByteArrayOutputStream(); String remoteLoc = jarURL + "/" + unslashedName; try { URL url = new URL(remoteLoc); is = url.openStream(); int i; while((i = is.read()) != -1) baos.write(i); buf = baos.toByteArray(); if (resources == null) resources = new HashMap(); resources.put(name, buf); } catch(Exception e) { return getResourceForward(unslashedName); } return new ByteArrayInputStream(buf); }