org.apache.fop.servlet

## Class ServletContextURIResolver

- java.lang.Object
- - org.apache.fop.servlet.ServletContextURIResolver

- All Implemented Interfaces:
    URIResolver

      public class ServletContextURIResolver
      extends Object
      implements URIResolver

  This class is a URIResolver implementation that provides access to resources in the WEB-INF directory of a web application using "servlet-content:" URIs.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `SERVLET_CONTEXT_PROTOCOL` The protocol name for the servlet context URIs.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServletContextURIResolver(jakarta.servlet.ServletContext servletContext)` Main constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Source` | `resolve(String href, String base)`
    `protected Source` | `resolveServletContextURI(String path)` Resolves the "servlet-context:" URI.

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### SERVLET_CONTEXT_PROTOCOL

          public static final String SERVLET_CONTEXT_PROTOCOL

      The protocol name for the servlet context URIs.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ServletContextURIResolver

          public ServletContextURIResolver(jakarta.servlet.ServletContext servletContext)

      Main constructor
      Parameters:
        `servletContext` - the servlet context to access the resources through

  - ### Method Detail

    - #### resolve

          public Source resolve(String href,
                                String base)
                         throws TransformerException

      Specified by:
        `resolve` in interface `URIResolver`
      Throws:
        `TransformerException`

    - #### resolveServletContextURI

          protected Source resolveServletContextURI(String path)
                                             throws TransformerException

      Resolves the "servlet-context:" URI.
      Parameters:
        `path` - the path part after the protocol (should start with a "/")
      Returns:
        the resolved Source or null if the resource was not found
      Throws:
        `TransformerException` - if no URL can be constructed from the path

Copyright © 2025 Apache Software Foundation. All rights reserved.