| java.lang.Object org.apache.struts.util.RequestUtils
RequestUtils | public class RequestUtils (Code) | | General purpose utility methods related to processing a servlet request
in the Struts controller framework.
version: $Rev: 471754 $ $Date: 2006-11-06 08:55:09 -0600 (Mon, 06 Nov 2006) $ |
Field Summary | |
protected static Log | log |
Method Summary | |
public static URL | absoluteURL(HttpServletRequest request, String path) | public static String | actionIdURL(ForwardConfig forward, HttpServletRequest request, ActionServlet servlet) Returns the true path of the destination action if the specified forward
is an action-aliased URL. | public static String | actionIdURL(String originalPath, ModuleConfig moduleConfig, ActionServlet servlet) Returns the true path of the destination action if the specified forward
is an action-aliased URL. | public static String | actionURL(HttpServletRequest request, ActionConfig action, String pattern) | public static Class | applicationClass(String className) | public static Class | applicationClass(String className, ClassLoader classLoader) | public static Object | applicationInstance(String className) Return a new instance of the specified fully qualified class name,
after loading the class from this web application's class loader. | public static Object | applicationInstance(String className, ClassLoader classLoader) Return a new instance of the specified fully qualified class name,
after loading the class from this web application's class loader. | public static ActionForm | createActionForm(HttpServletRequest request, ActionMapping mapping, ModuleConfig moduleConfig, ActionServlet servlet) Create (if necessary) and return an ActionForm instance
appropriate for this request. | public static ActionForm | createActionForm(FormBeanConfig config, ActionServlet servlet) | public static StringBuffer | createServerStringBuffer(String scheme, String server, int port) | public static StringBuffer | createServerUriStringBuffer(String scheme, String server, int port, String uri) | public static String | forwardURL(HttpServletRequest request, ForwardConfig forward) Return the context-relative URL that corresponds to the specified
ForwardConfig . | public static String | forwardURL(HttpServletRequest request, ForwardConfig forward, ModuleConfig moduleConfig) Return the context-relative URL that corresponds to the specified
ForwardConfig . | public static String | getServletMapping(ActionServlet servlet) | public static Locale | getUserLocale(HttpServletRequest request, String locale) Look up and return current user locale, based on the specified
parameters.
Parameters: request - The request used to lookup the Locale Parameters: locale - Name of the session attribute for our user's Locale. | public static void | populate(Object bean, HttpServletRequest request) Populate the properties of the specified JavaBean from the specified
HTTP request, based on matching each parameter name against the
corresponding JavaBeans "property setter" methods in the bean's class. | public static void | populate(Object bean, String prefix, String suffix, HttpServletRequest request) Populate the properties of the specified JavaBean from the specified
HTTP request, based on matching each parameter name (plus an optional
prefix and/or suffix) against the corresponding JavaBeans "property
setter" methods in the bean's class. | public static String | printableURL(URL url) Compute the printable representation of a URL, leaving off the
scheme/host/port part if no host is specified. | public static StringBuffer | requestToServerStringBuffer(HttpServletRequest request) Return StringBuffer representing the scheme, server,
and port number of the current request. | public static StringBuffer | requestToServerUriStringBuffer(HttpServletRequest request) Return the string representing the scheme, server, and port number
of the current request. | public static URL | requestURL(HttpServletRequest request) Return the URL representing the current request. | public static URL | serverURL(HttpServletRequest request) Return the URL representing the scheme, server, and port number of
the current request. |
log | protected static Log log(Code) | | Commons Logging instance.
|
absoluteURL | public static URL absoluteURL(HttpServletRequest request, String path) throws MalformedURLException(Code) | | Create and return an absolute URL for the specified context-relative
path, based on the server and context information in the specified
request.
Parameters: request - The servlet request we are processing Parameters: path - The context-relative path (must start with '/') absolute URL based on context-relative path throws: MalformedURLException - if we cannot create an absolute URL |
actionIdURL | public static String actionIdURL(ForwardConfig forward, HttpServletRequest request, ActionServlet servlet)(Code) | | Returns the true path of the destination action if the specified forward
is an action-aliased URL. This method version forms the URL based on
the current request; selecting the current module if the forward does not
explicitly contain a module path.
Parameters: forward - the forward config Parameters: request - the current request Parameters: servlet - the servlet handling the current request the context-relative URL of the action if the forward has an action identifier; otherwise null . since: Struts 1.3.6 |
actionIdURL | public static String actionIdURL(String originalPath, ModuleConfig moduleConfig, ActionServlet servlet)(Code) | | Returns the true path of the destination action if the specified forward
is an action-aliased URL. This method version forms the URL based on
the specified module.
Parameters: originalPath - the action-aliased path Parameters: moduleConfig - the module config for this request Parameters: servlet - the servlet handling the current request the context-relative URL of the action if the path has an action identifier; otherwise null . since: Struts 1.3.6 |
actionURL | public static String actionURL(HttpServletRequest request, ActionConfig action, String pattern)(Code) | | Return the context-relative URL that corresponds to the specified
ActionConfig , relative to the module associated with the
current modules's
ModuleConfig .
Parameters: request - The servlet request we are processing Parameters: action - ActionConfig to be evaluated Parameters: pattern - URL pattern used to map the controller servlet context-relative URL relative to the module since: Struts 1.1 |
applicationClass | public static Class applicationClass(String className) throws ClassNotFoundException(Code) | | Return the Class object for the specified fully
qualified class name, from this web application's class loader.
Parameters: className - Fully qualified class name to be loaded Class object throws: ClassNotFoundException - if the class cannot be found |
applicationClass | public static Class applicationClass(String className, ClassLoader classLoader) throws ClassNotFoundException(Code) | | Return the Class object for the specified fully
qualified class name, from this web application's class loader.
Parameters: className - Fully qualified class name to be loaded Parameters: classLoader - The desired classloader to use Class object throws: ClassNotFoundException - if the class cannot be found |
createActionForm | public static ActionForm createActionForm(HttpServletRequest request, ActionMapping mapping, ModuleConfig moduleConfig, ActionServlet servlet)(Code) | | Create (if necessary) and return an ActionForm instance
appropriate for this request. If no ActionForm instance
is required, return null .
Parameters: request - The servlet request we are processing Parameters: mapping - The action mapping for this request Parameters: moduleConfig - The configuration for this module Parameters: servlet - The action servlet ActionForm instance associated with this request |
createActionForm | public static ActionForm createActionForm(FormBeanConfig config, ActionServlet servlet)(Code) | | Create and return an ActionForm instance appropriate to
the information in config .
Does not perform any checks to see if an existing ActionForm exists
which could be reused.
Parameters: config - The configuration for the Form bean which is to becreated. Parameters: servlet - The action servlet ActionForm instance associated with this request |
createServerStringBuffer | public static StringBuffer createServerStringBuffer(String scheme, String server, int port)(Code) | | Return StringBuffer representing the scheme, server,
and port number of the current request.
Parameters: scheme - The scheme name to use Parameters: server - The server name to use Parameters: port - The port value to use StringBuffer in the form scheme: server: port since: Struts 1.2.0 |
createServerUriStringBuffer | public static StringBuffer createServerUriStringBuffer(String scheme, String server, int port, String uri)(Code) | | Return StringBuffer representing the scheme, server,
and port number of the current request.
Parameters: scheme - The scheme name to use Parameters: server - The server name to use Parameters: port - The port value to use Parameters: uri - The uri value to use StringBuffer in the form scheme: server: port since: Struts 1.2.0 |
forwardURL | public static String forwardURL(HttpServletRequest request, ForwardConfig forward)(Code) | | Return the context-relative URL that corresponds to the specified
ForwardConfig . The URL is calculated based on the
properties of the
ForwardConfig instance as follows:
- If the
contextRelative property is set, it is assumed
that the path property contains a path that is already
context-relative:
- If the
path property value starts with a slash, it is
returned unmodified. - If the
path property value
does not start with a slash, a slash is prepended.
- Acquire the
forwardPattern property from the
ControllerConfig for the application module used to
process this request. If no pattern was configured, default to a
pattern of $M$P , which is compatible with the hard-coded
mapping behavior in Struts 1.0.
- Process the acquired
forwardPattern , performing the
following substitutions:
- $M - Replaced by the module prefix for the
application module processing this request.
- $P - Replaced by the
path property of
the specified
ForwardConfig , prepended with a slash if it does
not start with one.
- $$ - Replaced by a single dollar sign
character.
- $x (where "x" is any charater not listed above) -
Silently omit these two characters from the result value. (This has
the side effect of causing all other $+letter combinations to be
reserved.)
Parameters: request - The servlet request we are processing Parameters: forward - ForwardConfig to be evaluated context-relative URL since: Struts 1.1 |
forwardURL | public static String forwardURL(HttpServletRequest request, ForwardConfig forward, ModuleConfig moduleConfig)(Code) | | Return the context-relative URL that corresponds to the specified
ForwardConfig . The URL is calculated based on the
properties of the
ForwardConfig instance as follows:
- If the
contextRelative property is set, it is assumed
that the path property contains a path that is already
context-relative:
- If the
path property value starts with a slash, it is
returned unmodified. - If the
path property value
does not start with a slash, a slash is prepended.
- Acquire the
forwardPattern property from the
ControllerConfig for the application module used to
process this request. If no pattern was configured, default to a
pattern of $M$P , which is compatible with the hard-coded
mapping behavior in Struts 1.0.
- Process the acquired
forwardPattern , performing the
following substitutions: - $M - Replaced by the
module prefix for the application module processing this request.
- $P - Replaced by the
path property of
the specified
ForwardConfig , prepended with a slash if it does
not start with one.
- $$ - Replaced by a single dollar sign
character.
- $x (where "x" is any charater not listed above) -
Silently omit these two characters from the result value. (This has
the side effect of causing all other $+letter combinations to be
reserved.)
Parameters: request - The servlet request we are processing Parameters: forward - ForwardConfig to be evaluated Parameters: moduleConfig - Base forward on this module config. context-relative URL since: Struts 1.2 |
getUserLocale | public static Locale getUserLocale(HttpServletRequest request, String locale)(Code) | | Look up and return current user locale, based on the specified
parameters.
Parameters: request - The request used to lookup the Locale Parameters: locale - Name of the session attribute for our user's Locale. Ifthis is null , the default locale key isused for the lookup. current user locale since: Struts 1.2 |
populate | public static void populate(Object bean, HttpServletRequest request) throws ServletException(Code) | | Populate the properties of the specified JavaBean from the specified
HTTP request, based on matching each parameter name against the
corresponding JavaBeans "property setter" methods in the bean's class.
Suitable conversion is done for argument types as described under
convert() .
Parameters: bean - The JavaBean whose properties are to be set Parameters: request - The HTTP request whose parameters are to be used topopulate bean properties throws: ServletException - if an exception is thrown while settingproperty values |
populate | public static void populate(Object bean, String prefix, String suffix, HttpServletRequest request) throws ServletException(Code) | | Populate the properties of the specified JavaBean from the specified
HTTP request, based on matching each parameter name (plus an optional
prefix and/or suffix) against the corresponding JavaBeans "property
setter" methods in the bean's class. Suitable conversion is done for
argument types as described under setProperties .
If you specify a non-null prefix and a non-null
suffix , the parameter name must match
both conditions for its value(s) to be used in
populating bean properties. If the request's content type is
"multipart/form-data" and the method is "POST", the
HttpServletRequest object will be wrapped in a
MultipartRequestWrapper
Parameters: bean - The JavaBean whose properties are to be set Parameters: prefix - The prefix (if any) to be prepend to bean property nameswhen looking for matching parameters Parameters: suffix - The suffix (if any) to be appended to bean propertynames when looking for matching parameters Parameters: request - The HTTP request whose parameters are to be used topopulate bean properties throws: ServletException - if an exception is thrown while settingproperty values |
printableURL | public static String printableURL(URL url)(Code) | | Compute the printable representation of a URL, leaving off the
scheme/host/port part if no host is specified. This will typically be
the case for URLs that were originally created from relative or
context-relative URIs.
Parameters: url - URL to render in a printable representation printable representation of a URL |
requestToServerStringBuffer | public static StringBuffer requestToServerStringBuffer(HttpServletRequest request)(Code) | | Return StringBuffer representing the scheme, server,
and port number of the current request. Server-relative URLs can be
created by simply appending the server-relative path (starting with
'/') to this.
Parameters: request - The servlet request we are processing URL representing the scheme, server, and port number of thecurrent request since: Struts 1.2.0 |
requestToServerUriStringBuffer | public static StringBuffer requestToServerUriStringBuffer(HttpServletRequest request)(Code) | | Return the string representing the scheme, server, and port number
of the current request. Server-relative URLs can be created by simply
appending the server-relative path (starting with '/') to this.
Parameters: request - The servlet request we are processing URL representing the scheme, server, and port number of thecurrent request since: Struts 1.2.0 |
requestURL | public static URL requestURL(HttpServletRequest request) throws MalformedURLException(Code) | | Return the URL representing the current request. This is equivalent
to HttpServletRequest.getRequestURL in Servlet 2.3.
Parameters: request - The servlet request we are processing URL representing the current request throws: MalformedURLException - if a URL cannot be created |
serverURL | public static URL serverURL(HttpServletRequest request) throws MalformedURLException(Code) | | Return the URL representing the scheme, server, and port number of
the current request. Server-relative URLs can be created by simply
appending the server-relative path (starting with '/') to this.
Parameters: request - The servlet request we are processing URL representing the scheme, server, and port number of thecurrent request throws: MalformedURLException - if a URL cannot be created |
|
|