org.apache.tiles.request.servlet

## Class ServletUtil

- java.lang.Object
- - org.apache.tiles.request.servlet.ServletUtil

-     public final class ServletUtil
      extends Object

  Utilities for Tiles request servlet support.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static ApplicationContext` | `getApplicationContext(javax.servlet.ServletContext servletContext)` Returns the application context getting it from the servlet context.
    `static javax.servlet.ServletContext` | `getServletContext(ApplicationContext applicationContext)` Gets a servlet context from a TilesApplicationContext.
    `static ServletRequest` | `getServletRequest(Request request)` Opens a TilesRequestContext until it finds a ServletTilesRequestContext.
    `static IOException` | `wrapServletException(javax.servlet.ServletException ex, String message)` Wraps a ServletException to create an IOException with the root cause if present.

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

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

- - ### Method Detail

    - #### wrapServletException

          public static IOException wrapServletException(javax.servlet.ServletException ex,
                                                         String message)

      Wraps a ServletException to create an IOException with the root cause if present.
      Parameters:
        `ex` - The exception to wrap.
        `message` - The message of the exception.
      Returns:
        The wrapped exception.

    - #### getApplicationContext

          public static ApplicationContext getApplicationContext(javax.servlet.ServletContext servletContext)

      Returns the application context getting it from the servlet context. It must be first saved creating a `ServletApplicationContext` and using `ApplicationAccess.register(ApplicationContext)`.
      Parameters:
        `servletContext` - The servlet context.
      Returns:
        The application context, if found, `null` otherwise.

    - #### getServletRequest

          public static ServletRequest getServletRequest(Request request)

      Opens a TilesRequestContext until it finds a ServletTilesRequestContext.
      Parameters:
        `request` - The request to open.
      Returns:
        The servlet-based request context.
      Throws:
        `NotAServletEnvironmentException` - If a servlet-based request context could not be found.

    - #### getServletContext

          public static javax.servlet.ServletContext getServletContext(ApplicationContext applicationContext)

      Gets a servlet context from a TilesApplicationContext.
      Parameters:
        `applicationContext` - The application context to analyze.
      Returns:
        The servlet context.
      Throws:
        `NotAServletEnvironmentException` - If the application context is not servlet-based.

Copyright © 2000–2026 Apache Software Foundation. All rights reserved.