Class ServletUtil
java.lang.Object
org.apache.tiles.request.jakarta.servlet.ServletUtil
Utilities for Tiles request servlet support.
Copied from Apache tiles-request-servlet 1.0.7 and adapted for Jakarta EE 9.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ApplicationContext
getApplicationContext
(ServletContext servletContext) Returns the application context getting it from the servlet context.static 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
(ServletException ex, String message) Wraps a ServletException to create an IOException with the root cause if present.
-
Method Details
-
wrapServletException
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
Returns the application context getting it from the servlet context. It must be first saved creating aServletApplicationContext
and usingApplicationAccess.register(ApplicationContext)
.- Parameters:
servletContext
- The servlet context.- Returns:
- The application context, if found,
null
otherwise.
-
getServletRequest
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
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.
-