parser.redirectEntity("web-jsptaglibrary_1_1.dtd",WebAppContext.class.getResource("/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd")); parser.redirectEntity("web-jsptaglibrary_1_2.dtd",WebAppContext.class.getResource("/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd")); parser.redirectEntity("web-jsptaglibrary_2_0.xsd",WebAppContext.class.getResource("/javax/servlet/jsp/resources/web-jsptaglibrary_2_0.xsd"));
parser.redirectEntity("web-jsptaglib_1_1.dtd",Loader.getResource(TagLibConfiguration.class,"javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd", false)); parser.redirectEntity("web-jsptaglib_1_2.dtd",Loader.getResource(TagLibConfiguration.class,"javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd", false)); parser.redirectEntity("web-jsptaglib_2_0.xsd",Loader.getResource(TagLibConfiguration.class,"javax/servlet/jsp/resources/web-jsptaglibrary_2_0.xsd", false)); parser.redirectEntity("web-jsptaglibrary_1_1.dtd",Loader.getResource(TagLibConfiguration.class,"javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd", false)); parser.redirectEntity("web-jsptaglibrary_1_2.dtd",Loader.getResource(TagLibConfiguration.class,"javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd", false)); parser.redirectEntity("web-jsptaglibrary_2_0.xsd",Loader.getResource(TagLibConfiguration.class,"javax/servlet/jsp/resources/web-jsptaglibrary_2_0.xsd", false));
    public void configureWebApp() throws Exception    {        Set tlds = new HashSet();                // Find tld's from web.xml        // When the XMLConfigurator (or other configurator) parsed the web.xml,        // It should have created aliases for all TLDs.  So search resources aliases        // for aliases ending in tld        if (_context.getResourceAliases()!=null &&             _context.getBaseResource()!=null &&             _context.getBaseResource().exists())        {            Iterator iter=_context.getResourceAliases().values().iterator();            while(iter.hasNext())            {                String location = (String)iter.next();                if (location!=null && location.toLowerCase().endsWith(".tld"))                {                    if (!location.startsWith("/"))                        location="/WEB-INF/"+location;                    Resource l=_context.getBaseResource().addPath(location);                    tlds.add(l);                }            }        }                // Look for any tlds in WEB-INF directly.        if (_context.getWebInf()!=null)        {            String[] contents = _context.getWebInf().list();            for (int i=0;i<contents.length;i++)            {                if (contents[i]!=null && contents[i].toLowerCase().endsWith(".tld"))                {                    Resource l=_context.getWebInf().addPath(contents[i]);                    tlds.add(l);                }                            }        }                // Look for tlds in any jars        List jars = getJarResourceList();        for (int i=0;i<jars.size();i++)        {            Resource jar=(Resource)jars.get(i);            Resource meta=Resource.newResource("jar:"+jar.getURL()+"!/META-INF/");            if (meta.exists())                findTLDs(tlds,meta);        }                // Create a TLD parser        XmlParser parser = new XmlParser(false);                parser.redirectEntity("web-jsptaglibrary_1_1.dtd",WebAppContext.class.getResource("/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd"));        parser.redirectEntity("web-jsptaglibrary_1_2.dtd",WebAppContext.class.getResource("/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd"));        parser.redirectEntity("web-jsptaglibrary_2_0.xsd",WebAppContext.class.getResource("/javax/servlet/jsp/resources/web-jsptaglibrary_2_0.xsd"));        parser.setXpath("/taglib/listener/listener-class");        // Parse all the discovered TLDs        Iterator iter = tlds.iterator();        while (iter.hasNext())        {            try            {                Resource tld = (Resource)iter.next();                if (Log.isDebugEnabled()) Log.debug("TLD="+tld);                                XmlParser.Node root = parser.parse(tld.getURL().toString());                                for (int i=0;i<root.size();i++)                {                    Object o=root.get(i);                    if (o instanceof XmlParser.Node)                    {                        XmlParser.Node node = (XmlParser.Node)o;                        if ("listener".equals(node.getTag()))                        {                            String className=node.getString("listener-class",false,true);                            if (Log.isDebugEnabled()) Log.debug("listener="+className);                                                        try                            {                                Class listenerClass=getWebAppContext().loadClass(className);                                EventListener l=(EventListener)listenerClass.newInstance();                                _context.addEventListener(l);                            }                            catch(Exception e)                            {                                Log.warn("Could not instantiate listener "+className,e);                            }                        }                    }                }            }            catch(Exception e)            {                Log.warn(e);            }        }    }