* needs the URI to TLD mappings from scan web.xml whereas TldConfig needs
* to scan the actual TLD files.
*/
private void tldScanWebXml() throws Exception {
WebXml webXml = null;
try {
webXml = new WebXml(ctxt);
if (webXml.getInputSource() == null) {
return;
}
// Parse the web application deployment descriptor
TreeNode webtld = null;
webtld = new ParserUtils().parseXMLDocument(webXml.getSystemId(),
webXml.getInputSource());
// Allow taglib to be an element of the root or jsp-config (JSP2.0)
TreeNode jspConfig = webtld.findChild("jsp-config");
if (jspConfig != null) {
webtld = jspConfig;
}
Iterator<TreeNode> taglibs = webtld.findChildren("taglib");
while (taglibs.hasNext()) {
// Parse the next <taglib> element
TreeNode taglib = taglibs.next();
String tagUri = null;
String tagLoc = null;
TreeNode child = taglib.findChild("taglib-uri");
if (child != null)
tagUri = child.getBody();
child = taglib.findChild("taglib-location");
if (child != null)
tagLoc = child.getBody();
// Save this location if appropriate
if (tagLoc == null)
continue;
if (uriType(tagLoc) == NOROOT_REL_URI)
tagLoc = "/WEB-INF/" + tagLoc;
TldLocation location;
if (tagLoc.endsWith(JAR_EXT)) {
location = new TldLocation("META-INF/taglib.tld", ctxt.getResource(tagLoc).toString());
} else {
location = new TldLocation(tagLoc);
}
mappings.put(tagUri, location);
}
} finally {
if (webXml != null) {
webXml.close();
}
}
}