# Class TldCache

java.lang.Object
org.apache.jasper.compiler.TldCache

public class TldCache extends Object
This class caches parsed instances of TLD files to remove the need for the same TLD to be parsed for each JSP that references it. It does not protect against multiple threads processing the same new TLD, but it does ensure that each all threads will use the same TLD object after parsing.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `SERVLET_CONTEXT_ATTRIBUTE_NAME`
  The ServletContext attribute name used to store the TldCache instance.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TldCache(ServletContext servletContext, Map<String, TldResourcePath> uriTldResourcePathMap, Map<TldResourcePath, TaglibXml> tldResourcePathTaglibXmlMap)`
  Creates a new TldCache.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static TldCache`
  `getInstance(ServletContext servletContext)`
  Returns the TldCache instance for the given servlet context.
  `TaglibXml`
  `getTaglibXml(TldResourcePath tldResourcePath)`
  Returns the parsed tag library XML for the given resource path.
  `TldResourcePath`
  `getTldResourcePath(String uri)`
  Returns the resource path for the given TLD URI.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### SERVLET_CONTEXT_ATTRIBUTE_NAME

    public static final String SERVLET_CONTEXT_ATTRIBUTE_NAME
    The ServletContext attribute name used to store the TldCache instance.

- ## Constructor Details

  - ### TldCache

    public TldCache(ServletContext servletContext, Map<String, TldResourcePath> uriTldResourcePathMap, Map<TldResourcePath, TaglibXml> tldResourcePathTaglibXmlMap)
    Creates a new TldCache.
    Parameters:
      `servletContext` - the servlet context
      `uriTldResourcePathMap` - the pre-scanned URI to resource path mappings
      `tldResourcePathTaglibXmlMap` - the pre-parsed TLD data

- ## Method Details

  - ### getInstance

    public static TldCache getInstance(ServletContext servletContext)
    Returns the TldCache instance for the given servlet context.
    Parameters:
      `servletContext` - the servlet context
    Returns:
      the TldCache instance

  - ### getTldResourcePath

    public TldResourcePath getTldResourcePath(String uri)
    Returns the resource path for the given TLD URI.
    Parameters:
      `uri` - the TLD URI
    Returns:
      the resource path, or null if not found

  - ### getTaglibXml

    public TaglibXml getTaglibXml(TldResourcePath tldResourcePath) throws JasperException
    Returns the parsed tag library XML for the given resource path.
    Parameters:
      `tldResourcePath` - the TLD resource path
    Returns:
      the parsed tag library XML, or null if not found
    Throws:
      `JasperException` - if an error occurs during parsing