in freemarker-javax-servlet/src/main/java/freemarker/ext/jsp/TaglibFactory.java [182:270]
public TemplateModel get(final String taglibUri) throws TemplateModelException {
synchronized (lock) {
{
final Taglib taglib = (Taglib) taglibs.get(taglibUri);
if (taglib != null) {
return taglib;
}
}
boolean failedTldListAlreadyIncluded = false;
final TldLocation tldLocation;
final String normalizedTaglibUri;
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Locating TLD for taglib URI " + StringUtil.jQuoteNoXSS(taglibUri) + ".");
}
TldLocation explicitlyMappedTldLocation = getExplicitlyMappedTldLocation(taglibUri);
if (explicitlyMappedTldLocation != null) {
tldLocation = explicitlyMappedTldLocation;
normalizedTaglibUri = taglibUri;
} else {
// Taglib URI must be directly the path (no mapping).
final int urlType;
try {
urlType = getUriType(taglibUri);
} catch (MalformedURLException e) {
throw new TaglibGettingException("Malformed taglib URI: " + StringUtil.jQuote(taglibUri), e);
}
if (urlType == URL_TYPE_RELATIVE) {
normalizedTaglibUri = resolveRelativeUri(taglibUri);
} else if (urlType == URL_TYPE_ABSOLUTE) {
normalizedTaglibUri = taglibUri;
} else if (urlType == URL_TYPE_FULL) {
// Per spec., full URI-s can only be resolved through explicit mapping
String failedTLDsList = getFailedTLDsList();
failedTldListAlreadyIncluded = true;
throw new TaglibGettingException("No TLD was found for the "
+ StringUtil.jQuoteNoXSS(taglibUri) + " JSP taglib URI. (TLD-s are searched according "
+ "the JSP 2.2 specification. In development- and embedded-servlet-container "
+ "setups you may also need the "
+ "\"" + FreemarkerServlet.INIT_PARAM_META_INF_TLD_LOCATIONS + "\" and "
+ "\"" + FreemarkerServlet.INIT_PARAM_CLASSPATH_TLDS + "\" "
+ FreemarkerServlet.class.getName() + " init-params or the similar system "
+ "properites."
+ (failedTLDsList == null
? ""
: " Also note these TLD-s were skipped earlier due to errors; "
+ "see error in the log: " + failedTLDsList
) + ")");
} else {
throw new BugException();
}
if (!normalizedTaglibUri.equals(taglibUri)) {
final Taglib taglib = (Taglib) taglibs.get(normalizedTaglibUri);
if (taglib != null) {
return taglib;
}
}
tldLocation = isJarPath(normalizedTaglibUri)
? new ServletContextJarEntryTldLocation(
normalizedTaglibUri, DEFAULT_TLD_RESOURCE_PATH)
: new ServletContextTldLocation(normalizedTaglibUri);
}
} catch (Exception e) {
String failedTLDsList = failedTldListAlreadyIncluded ? null : getFailedTLDsList();
throw new TemplateModelException(
"Error while looking for TLD file for " + StringUtil.jQuoteNoXSS(taglibUri)
+ "; see cause exception."
+ (failedTLDsList == null
? ""
: " (Note: These TLD-s were skipped earlier due to errors; "
+ "see errors in the log: " + failedTLDsList + ")"),
e);
}
try {
return loadTaglib(tldLocation, normalizedTaglibUri);
} catch (Exception e) {
throw new TemplateModelException("Error while loading tag library for URI "
+ StringUtil.jQuoteNoXSS(normalizedTaglibUri) + " from TLD location "
+ StringUtil.jQuoteNoXSS(tldLocation) + "; see cause exception.",
e);
}
}
}