Search in sources :

Example 1 with TldCache

use of org.apache.jasper.compiler.TldCache in project tomcat by apache.

the class JasperInitializer method onStartup.

@Override
public void onStartup(Set<Class<?>> types, ServletContext context) throws ServletException {
    if (log.isDebugEnabled()) {
        log.debug(Localizer.getMessage(MSG + ".onStartup", context.getServletContextName()));
    }
    // Setup a simple default Instance Manager
    if (context.getAttribute(InstanceManager.class.getName()) == null) {
        context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
    }
    boolean validate = Boolean.parseBoolean(context.getInitParameter(Constants.XML_VALIDATION_TLD_INIT_PARAM));
    String blockExternalString = context.getInitParameter(Constants.XML_BLOCK_EXTERNAL_INIT_PARAM);
    boolean blockExternal;
    if (blockExternalString == null) {
        blockExternal = true;
    } else {
        blockExternal = Boolean.parseBoolean(blockExternalString);
    }
    // scan the application for TLDs
    TldScanner scanner = newTldScanner(context, true, validate, blockExternal);
    try {
        scanner.scan();
    } catch (IOException | SAXException e) {
        throw new ServletException(e);
    }
    // add any listeners defined in TLDs
    for (String listener : scanner.getListeners()) {
        context.addListener(listener);
    }
    context.setAttribute(TldCache.SERVLET_CONTEXT_ATTRIBUTE_NAME, new TldCache(context, scanner.getUriTldResourcePathMap(), scanner.getTldResourcePathTaglibXmlMap()));
}
Also used : ServletException(javax.servlet.ServletException) TldCache(org.apache.jasper.compiler.TldCache) InstanceManager(org.apache.tomcat.InstanceManager) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) IOException(java.io.IOException) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) SAXException(org.xml.sax.SAXException)

Example 2 with TldCache

use of org.apache.jasper.compiler.TldCache in project tomcat by apache.

the class JspC method initServletContext.

protected void initServletContext(ClassLoader classLoader) throws IOException, JasperException {
    // TODO: should we use the Ant Project's log?
    PrintWriter log = new PrintWriter(System.out);
    URL resourceBase = new File(uriRoot).getCanonicalFile().toURI().toURL();
    context = new JspCServletContext(log, resourceBase, classLoader, isValidateXml(), isBlockExternal());
    if (isValidateTld()) {
        context.setInitParameter(Constants.XML_VALIDATION_TLD_INIT_PARAM, "true");
    }
    initTldScanner(context, classLoader);
    try {
        scanner.scan();
    } catch (SAXException e) {
        throw new JasperException(e);
    }
    tldCache = new TldCache(context, scanner.getUriTldResourcePathMap(), scanner.getTldResourcePathTaglibXmlMap());
    context.setAttribute(TldCache.SERVLET_CONTEXT_ATTRIBUTE_NAME, tldCache);
    rctxt = new JspRuntimeContext(context, this);
    jspConfig = new JspConfig(context);
    tagPluginManager = new TagPluginManager(context);
}
Also used : TldCache(org.apache.jasper.compiler.TldCache) JspConfig(org.apache.jasper.compiler.JspConfig) JspRuntimeContext(org.apache.jasper.compiler.JspRuntimeContext) TagPluginManager(org.apache.jasper.compiler.TagPluginManager) File(java.io.File) JspCServletContext(org.apache.jasper.servlet.JspCServletContext) URL(java.net.URL) PrintWriter(java.io.PrintWriter) SAXException(org.xml.sax.SAXException)

Aggregations

TldCache (org.apache.jasper.compiler.TldCache)2 SAXException (org.xml.sax.SAXException)2 File (java.io.File)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 URL (java.net.URL)1 ServletException (javax.servlet.ServletException)1 JspConfig (org.apache.jasper.compiler.JspConfig)1 JspRuntimeContext (org.apache.jasper.compiler.JspRuntimeContext)1 TagPluginManager (org.apache.jasper.compiler.TagPluginManager)1 JspCServletContext (org.apache.jasper.servlet.JspCServletContext)1 InstanceManager (org.apache.tomcat.InstanceManager)1 SimpleInstanceManager (org.apache.tomcat.SimpleInstanceManager)1