public class ServletUtils extends Object
A set of utility methods for supporting and using VelocityTools in the servlet environment.
Modifier and Type | Field and Description |
---|---|
static String |
ALT_VELOCITY_VIEW_KEY |
static String |
CONFIGURATION_KEY
Key used to access a live
FactoryConfiguration previously
placed in the ServletContext attributes. |
static ServletUtils |
INSTANCE |
static String |
SHARED_CONFIG_PARAM |
static String |
VELOCITY_VIEW_KEY |
Modifier | Constructor and Description |
---|---|
protected |
ServletUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
combinePath(String before,
String after)
If end is null, this will return start and vice versa.
|
static Object |
findTool(String key,
javax.servlet.http.HttpServletRequest request) |
static Object |
findTool(String key,
javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletContext application) |
static Object |
findTool(String key,
javax.servlet.ServletContext application) |
static Object |
findTool(String key,
String toolboxKey,
javax.servlet.http.HttpServletRequest request) |
static Object |
findTool(String key,
String toolboxKey,
javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletContext application) |
static Object |
findTool(String key,
String toolboxKey,
javax.servlet.ServletContext application) |
static FactoryConfiguration |
getConfiguration(javax.servlet.ServletContext application) |
static FactoryConfiguration |
getConfiguration(String path,
javax.servlet.ServletContext application) |
static InputStream |
getInputStream(String path,
javax.servlet.ServletContext application) |
ServletUtils |
getInstance() |
static Object |
getMutex(javax.servlet.http.HttpSession session,
String key,
Object caller)
Returns a mutex (lock object) unique to the specified session
and stored under the specified key to allow for reliable
synchronization on the session.
|
static String |
getPath(javax.servlet.http.HttpServletRequest request)
Retrieves the path for the specified request regardless of
whether this is a direct request or an include by the
RequestDispatcher.
|
static URL |
getURL(String path,
javax.servlet.ServletContext application) |
static VelocityView |
getVelocityView(javax.servlet.FilterConfig config)
Returns the shared
VelocityView for the specified
FilterConfig 's context. |
static VelocityView |
getVelocityView(JeeConfig config)
Returns the shared
VelocityView for the specified
JeeConfig 's context. |
static VelocityView |
getVelocityView(javax.servlet.ServletConfig config)
Returns the shared
VelocityView for the specified
ServletConfig 's context. |
static VelocityView |
getVelocityView(javax.servlet.ServletContext application)
Returns the shared
VelocityView for the specified
ServletContext . |
static VelocityView |
getVelocityView(javax.servlet.ServletContext application,
boolean createIfMissing)
Returns the shared
VelocityView for the specified
ServletContext . |
protected static boolean |
isWebappResource(String path) |
public static final String VELOCITY_VIEW_KEY
public static final String SHARED_CONFIG_PARAM
public static final String ALT_VELOCITY_VIEW_KEY
public static final String CONFIGURATION_KEY
FactoryConfiguration
previously
placed in the ServletContext attributes.public static final ServletUtils INSTANCE
public ServletUtils getInstance()
public static String getPath(javax.servlet.http.HttpServletRequest request)
request
- servlet requestpublic static VelocityView getVelocityView(javax.servlet.ServletConfig config)
VelocityView
for the specified
ServletConfig
's context. If one has not yet been created, it
will create, store it for future access, and then return it.config
- servlet configpublic static VelocityView getVelocityView(javax.servlet.FilterConfig config)
VelocityView
for the specified
FilterConfig
's context. If one has not yet been created, it
will create, store it for future access, and then return it.config
- filter configpublic static VelocityView getVelocityView(JeeConfig config)
VelocityView
for the specified
JeeConfig
's context. If one has not yet been created, it
will create, store it for future access, and then return it.config
- configuration parameters container (webapp, servlet or filter)public static VelocityView getVelocityView(javax.servlet.ServletContext application)
VelocityView
for the specified
ServletContext
. If one has not yet been created,
it will create one, store it for future access, and then return it.application
- servlet contextpublic static VelocityView getVelocityView(javax.servlet.ServletContext application, boolean createIfMissing)
VelocityView
for the specified
ServletContext
. If one has not yet been created and
the second parameter is true
, then it will
create one, store it for future access, and return it.application
- servlet contextcreateIfMissing
- whether to create VelocityView if not yet builtpublic static Object findTool(String key, String toolboxKey, javax.servlet.ServletContext application)
public static Object findTool(String key, String toolboxKey, javax.servlet.http.HttpServletRequest request)
public static Object findTool(String key, javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext application)
public static Object findTool(String key, String toolboxKey, javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext application)
protected static boolean isWebappResource(String path)
public static InputStream getInputStream(String path, javax.servlet.ServletContext application)
public static FactoryConfiguration getConfiguration(javax.servlet.ServletContext application)
public static FactoryConfiguration getConfiguration(String path, javax.servlet.ServletContext application)
public static Object getMutex(javax.servlet.http.HttpSession session, String key, Object caller)
session
- HTTP sessionkey
- mutex keycaller
- caller objectpublic static String combinePath(String before, String after)
before
- start pathafter
- end pathCopyright © 2002–2021 The Apache Software Foundation. All rights reserved.