|
|||||||||
| Home >> All >> org >> apache >> struts >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.struts.util
Class RequestUtils

java.lang.Objectorg.apache.struts.util.RequestUtils
- public class RequestUtils
- extends java.lang.Object
General purpose utility methods related to processing a servlet request in the Struts controller framework.
- Version:
- $Rev: 384422 $ $Date: 2006-03-09 04:17:18 +0000 (Thu, 09 Mar 2006) $
| Field Summary | |
protected static org.apache.commons.logging.Log |
log
Commons Logging instance. |
| Constructor Summary | |
RequestUtils()
|
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
log
protected static org.apache.commons.logging.Log log
Commons Logging instance.
| Constructor Detail |
RequestUtils
public RequestUtils()
| Method Detail |
absoluteURL
public static java.net.URL absoluteURL(javax.servlet.http.HttpServletRequest request, java.lang.String path) throws java.net.MalformedURLException
Create and return an absolute URL for the specified context-relative path, based on the server and context information in the specified request.
applicationClass
public static java.lang.Class applicationClass(java.lang.String className) throws java.lang.ClassNotFoundException
Return the
Classobject for the specified fully qualified class name, from this web application's class loader.
applicationInstance
public static java.lang.Object applicationInstance(java.lang.String className) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException
Return a new instance of the specified fully qualified class name, after loading the class from this web application's class loader. The specified class MUST have a public zero-arguments constructor.
createActionForm
public static org.apache.struts.action.ActionForm createActionForm(javax.servlet.http.HttpServletRequest request, org.apache.struts.action.ActionMapping mapping, org.apache.struts.config.ModuleConfig moduleConfig, org.apache.struts.action.ActionServlet servlet)
Create (if necessary) and return an
ActionForminstance appropriate for this request. If noActionForminstance is required, returnnull.
lookupActionForm
private static org.apache.struts.action.ActionForm lookupActionForm(javax.servlet.http.HttpServletRequest request, java.lang.String attribute, java.lang.String scope)
canReuseActionForm
private static boolean canReuseActionForm(org.apache.struts.action.ActionForm instance, org.apache.struts.config.FormBeanConfig config) throws java.lang.ClassNotFoundException
Determine whether
instanceofActionFormis suitable for re-use as an instance of the form described byconfig.
createActionForm
public static org.apache.struts.action.ActionForm createActionForm(org.apache.struts.config.FormBeanConfig config, org.apache.struts.action.ActionServlet servlet)
Create and return an
ActionForminstance appropriate to the information inconfig.Does not perform any checks to see if an existing ActionForm exists which could be reused.
getUserLocale
public static java.util.Locale getUserLocale(javax.servlet.http.HttpServletRequest request, java.lang.String locale)
Look up and return current user locale, based on the specified parameters.
- Since:
- Struts 1.2
populate
public static void populate(java.lang.Object bean, javax.servlet.http.HttpServletRequest request) throws javax.servlet.ServletException
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().
populate
public static void populate(java.lang.Object bean, java.lang.String prefix, java.lang.String suffix, javax.servlet.http.HttpServletRequest request) throws javax.servlet.ServletException
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
prefixand a non-nullsuffix, 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", theHttpServletRequestobject will be wrapped in aMultipartRequestWrapper
getMultipartHandler
private static org.apache.struts.upload.MultipartRequestHandler getMultipartHandler(javax.servlet.http.HttpServletRequest request) throws javax.servlet.ServletException
Try to locate a multipart request handler for this request. First, look for a mapping-specific handler stored for us under an attribute. If one is not present, use the global multipart handler, if there is one.
getAllParametersForMultipartRequest
private static java.util.Map getAllParametersForMultipartRequest(javax.servlet.http.HttpServletRequest request, org.apache.struts.upload.MultipartRequestHandler multipartHandler)
Create a
Mapcontaining all of the parameters supplied for a multipart request, keyed by parameter name. In addition to text and file elements from the multipart body, query string parameters are included as well.
printableURL
public static java.lang.String printableURL(java.net.URL url)
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.
actionURL
public static java.lang.String actionURL(javax.servlet.http.HttpServletRequest request, org.apache.struts.config.ActionConfig action, java.lang.String pattern)
Return the context-relative URL that corresponds to the specified org.apache.struts.config.ActionConfig, relative to the module associated with the current modules's org.apache.struts.config.ModuleConfig.
- Since:
- Struts 1.1
forwardURL
public static java.lang.String forwardURL(javax.servlet.http.HttpServletRequest request, org.apache.struts.config.ForwardConfig forward)
Return the context-relative URL that corresponds to the specified
ForwardConfig. The URL is calculated based on the properties of the org.apache.struts.config.ForwardConfig instance as follows:- If the
contextRelativeproperty is set, it is assumed that thepathproperty contains a path that is already context-relative:- If the
pathproperty value starts with a slash, it is returned unmodified. - If the
pathproperty value does not start with a slash, a slash is prepended.
- If the
- Acquire the
forwardPatternproperty from theControllerConfigfor 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
pathproperty of the specified org.apache.struts.config.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.)
- Since:
- Struts 1.1
- If the
forwardURL
public static java.lang.String forwardURL(javax.servlet.http.HttpServletRequest request, org.apache.struts.config.ForwardConfig forward, org.apache.struts.config.ModuleConfig moduleConfig)
Return the context-relative URL that corresponds to the specified
ForwardConfig. The URL is calculated based on the properties of the org.apache.struts.config.ForwardConfig instance as follows:- If the
contextRelativeproperty is set, it is assumed that thepathproperty contains a path that is already context-relative:- If the
pathproperty value starts with a slash, it is returned unmodified. - If the
pathproperty value does not start with a slash, a slash is prepended.
- If the
- Acquire the
forwardPatternproperty from theControllerConfigfor 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
pathproperty of the specified org.apache.struts.config.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.)
- Since:
- Struts 1.2
- If the
requestURL
public static java.net.URL requestURL(javax.servlet.http.HttpServletRequest request) throws java.net.MalformedURLException
Return the URL representing the current request. This is equivalent to
HttpServletRequest.getRequestURLin Servlet 2.3.
serverURL
public static java.net.URL serverURL(javax.servlet.http.HttpServletRequest request) throws java.net.MalformedURLException
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.
requestToServerUriStringBuffer
public static java.lang.StringBuffer requestToServerUriStringBuffer(javax.servlet.http.HttpServletRequest request)
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.
- Since:
- Struts 1.2.0
requestToServerStringBuffer
public static java.lang.StringBuffer requestToServerStringBuffer(javax.servlet.http.HttpServletRequest request)
Return
StringBufferrepresenting 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.- Since:
- Struts 1.2.0
createServerStringBuffer
public static java.lang.StringBuffer createServerStringBuffer(java.lang.String scheme, java.lang.String server, int port)
Return
StringBufferrepresenting the scheme, server, and port number of the current request.- Since:
- Struts 1.2.0
createServerUriStringBuffer
public static java.lang.StringBuffer createServerUriStringBuffer(java.lang.String scheme, java.lang.String server, int port, java.lang.String uri)
Return
StringBufferrepresenting the scheme, server, and port number of the current request.- Since:
- Struts 1.2.0
selectModule
public static void selectModule(java.lang.String prefix, javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext context)
- Deprecated. Use
ModuleUtils.selectModule(String,HttpServletRequest,ServletContext)55 instead. This will be removed after Struts 1.2.Select the module to which the specified request belongs, and add corresponding request attributes to this request.
- Since:
- Struts 1.1
selectModule
public static void selectModule(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext context)
- Deprecated. Use
ModuleUtils.selectModule(HttpServletRequest,ServletContext)55 instead. This will be removed after Struts 1.2.Select the module to which the specified request belongs, and add corresponding request attributes to this request.
getModuleName
public static java.lang.String getModuleName(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext context)
- Deprecated. Use Use
ModuleUtils.getModuleName(HttpServletRequest,ServletContext)55 instead. This will be removed after Struts 1.2.- Get the module name to which the specified request belong.
- Get the module name to which the specified request belong.
getModuleName
public static java.lang.String getModuleName(java.lang.String matchPath, javax.servlet.ServletContext context)
- Deprecated. Use
ModuleUtils.getModuleName(String,ServletContext)55 instead. This will be removed after Struts 1.2.Get the module name to which the specified uri belong.
getRequestModuleConfig
public static org.apache.struts.config.ModuleConfig getRequestModuleConfig(javax.servlet.http.HttpServletRequest request)
- Deprecated. Use
ModuleUtils.getModuleConfig(HttpServletRequest)55 instead. This will be removed after Struts 1.2.Return the current
ModuleConfigobject stored in request, if it exists, null otherwise. This method can be used by a org.apache.struts.action.PlugIn to retrieve the current module config object. If no moduleConfig is found, this means that the request hasn't hit the server through the Struts servlet. The appropriate module config can be set and found with.selectModule(HttpServletRequest, ServletContext)55- Since:
- Struts 1.1
getModuleConfig
public static org.apache.struts.config.ModuleConfig getModuleConfig(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext context)
- Deprecated. Use
ModuleUtils.getModuleConfig(HttpServletRequest,ServletContext)55 instead. This will be removed after Struts 1.2.Return the ModuleConfig object is it exists, null otherwise.
- Since:
- Struts 1.1
getModulePrefixes
public static java.lang.String[] getModulePrefixes(javax.servlet.ServletContext context)
- Deprecated. Use
ModuleUtils.getModulePrefixes(ServletContext)55 instead. This will be removed after Struts 1.2.Return the list of module prefixes that are defined for this web application. NOTE - the "" prefix for the default module is not included in this list.
- Since:
- Struts 1.1
computeParameters
public static java.util.Map computeParameters(javax.servlet.jsp.PageContext pageContext, java.lang.String paramId, java.lang.String paramName, java.lang.String paramProperty, java.lang.String paramScope, java.lang.String name, java.lang.String property, java.lang.String scope, boolean transaction) throws javax.servlet.jsp.JspException
- Deprecated. This will be removed after Struts 1.2.
Use TagUtils.computeParameters(PageContext,String,String,String,String,String,String,String,boolean)>
TagUtils.computeParameters(PageContext,String,String,String,String,String,String,String,boolean)55 instead.Compute a set of query parameters that will be dynamically added to a generated URL. The returned Map is keyed by parameter name, and the values are either null (no value specified), a String (single value specified), or a String[] array (multiple values specified). Parameter names correspond to the corresponding attributes of the
<html:link>tag. If no query parameters are identified, returnnull.
computeURL
public static java.lang.String computeURL(javax.servlet.jsp.PageContext pageContext, java.lang.String forward, java.lang.String href, java.lang.String page, java.util.Map params, java.lang.String anchor, boolean redirect) throws java.net.MalformedURLException
- Deprecated. This will be removed after Struts 1.2
Use
computeURL(PageContext, String, String, String, String, Map, String, boolean)55 instead.Compute a hyperlink URL based on the
forward,hreforpageparameter that is not null.
computeURL
public static java.lang.String computeURL(javax.servlet.jsp.PageContext pageContext, java.lang.String forward, java.lang.String href, java.lang.String page, java.lang.String action, java.util.Map params, java.lang.String anchor, boolean redirect) throws java.net.MalformedURLException
- Deprecated. This will be removed after Struts 1.2.
Use TagUtils.computeURL(PageContext,String,String,String,String,String,Map,String, boolean)>
TagUtils.computeURL(PageContext,String,String,String,String,String,Map,String, boolean)55 instead.Compute a hyperlink URL based on the
forward,href,actionorpageparameter that is not null. The returned URL will have already been passed toresponse.encodeURL()for adding a session identifier.
computeURL
public static java.lang.String computeURL(javax.servlet.jsp.PageContext pageContext, java.lang.String forward, java.lang.String href, java.lang.String page, java.lang.String action, java.util.Map params, java.lang.String anchor, boolean redirect, boolean encodeSeparator) throws java.net.MalformedURLException
- Deprecated. This will be removed after Struts 1.2.
Use TagUtils.computeURL(PageContext,String,String,String,String,String,Map,String,boolean,boolean)>
TagUtils.computeURL(PageContext,String,String,String,String,String,Map,String,boolean,boolean)55 instead.Compute a hyperlink URL based on the
forward,href,actionorpageparameter that is not null. The returned URL will have already been passed toresponse.encodeURL()for adding a session identifier.
getActionMappingName
public static java.lang.String getActionMappingName(java.lang.String action)
- Deprecated. This will be removed after Struts 1.2.
Use TagUtils.getActionMappingName(String)>
TagUtils.getActionMappingName(String)55 instead.Return the form action converted into an action mapping path. The value of the
actionproperty is manipulated as follows in computing the name of the requested mapping:- Any filename extension is removed (on the theory that extension mapping is being used to select the controller servlet).
- If the resulting value does not start with a slash, then a slash is prepended.
getActionMappingURL
public static java.lang.String getActionMappingURL(java.lang.String action, javax.servlet.jsp.PageContext pageContext)
- Deprecated. This will be removed after Struts 1.2.
Use TagUtils.getActionMappingURL(String,PageContext)>
TagUtils.getActionMappingURL(String,PageContext)55 instead.Return the form action converted into a server-relative URL.
lookup
public static java.lang.Object lookup(javax.servlet.jsp.PageContext pageContext, java.lang.String name, java.lang.String scopeName) throws javax.servlet.jsp.JspException
- Deprecated. This will be removed after Struts 1.2.
Use TagUtils.lookup(PageContext,String,String)>
TagUtils.lookup(PageContext,String,String)55 instead.Locate and return the specified bean, from an optionally specified scope, in the specified page context. If no such bean is found, return
nullinstead. If an exception is thrown, it will have already been saved via a call tosaveException.
getScope
public static int getScope(java.lang.String scopeName) throws javax.servlet.jsp.JspException
- Deprecated. This will be removed after Struts 1.2.
Use TagUtils.getScope(String)>
TagUtils.getScope(String)55 instead.Converts the scope name into its corresponding PageContext constant value.
- Since:
- Struts 1.1
lookup
public static java.lang.Object lookup(javax.servlet.jsp.PageContext pageContext, java.lang.String name, java.lang.String property, java.lang.String scope) throws javax.servlet.jsp.JspException
- Deprecated. This will be removed after Struts 1.2.
Use TagUtils.lookup(PageContext,String,String,String)>
TagUtils.lookup(PageContext,String,String,String)55 instead.Locate and return the specified property of the specified bean, from an optionally specified scope, in the specified page context. If an exception is thrown, it will have already been saved via a call to
saveException.
retrieveUserLocale
public static java.util.Locale retrieveUserLocale(javax.servlet.jsp.PageContext pageContext, java.lang.String locale)
- Deprecated. This will be removed after Struts 1.2.
Use TagUtils.getUserLocale(PageContext,String)>
TagUtils.getUserLocale(PageContext,String)55 instead.Look up and return current user locale, based on the specified parameters.
message
public static java.lang.String message(javax.servlet.jsp.PageContext pageContext, java.lang.String bundle, java.lang.String locale, java.lang.String key) throws javax.servlet.jsp.JspException
- Deprecated. Use TagUtils.message(PageContext,String,String,String)>
TagUtils.message(PageContext,String,String,String)55 instead. This will be removed after Struts 1.2.Look up and return a message string, based on the specified parameters.
message
public static java.lang.String message(javax.servlet.jsp.PageContext pageContext, java.lang.String bundle, java.lang.String locale, java.lang.String key, java.lang.Object[] args) throws javax.servlet.jsp.JspException
- Deprecated. Use TagUtils.message(PageContext,String,String,String,Object[])>
TagUtils.message(PageContext,String,String,String,Object[])55 instead. This will be removed after Struts 1.2.- Look up and return a message string, based on the specified parameters.
- Look up and return a message string, based on the specified parameters.
present
public static boolean present(javax.servlet.jsp.PageContext pageContext, java.lang.String bundle, java.lang.String locale, java.lang.String key) throws javax.servlet.jsp.JspException
- Deprecated. Use TagUtils.present(PageContext ,String,String,String)>
TagUtils.present(PageContext ,String,String,String)55 instead. This will be removed after Struts 1.2.Return true if a message string for the specified message key is present for the specified Locale.
pageURL
public static java.lang.String pageURL(javax.servlet.http.HttpServletRequest request, java.lang.String page)
- Deprecated. Use TagUtils.pageURL(HttpServletRequest request, String page, ModuleConfig moduleConfig)>
TagUtils.pageURL(HttpServletRequest request, String page, ModuleConfig moduleConfig)55 instead. This will be removed after Struts 1.2.Return the context-relative URL that corresponds to the specified
pageattribute value, calculated based on thepagePatternproperty of the current module's org.apache.struts.config.ModuleConfig.- Since:
- Struts 1.1
saveException
public static void saveException(javax.servlet.jsp.PageContext pageContext, java.lang.Throwable exception)
- Deprecated. Use TagUtils.saveException(PageContext,Throwable)>
TagUtils.saveException(PageContext,Throwable)55 instead. This will be removed after Struts 1.2.Save the specified exception as a request attribute for later use.
getModuleConfig
public static org.apache.struts.config.ModuleConfig getModuleConfig(javax.servlet.jsp.PageContext pageContext)
- Deprecated. Use TagUtils.getModuleConfig(PageContext)>
TagUtils.getModuleConfig(PageContext)55 instead. This will be removed after Struts 1.2.Return the
ModuleConfigobject if it exists, null if otherwise.- Since:
- Struts 1.1
getActionMessages
public static org.apache.struts.action.ActionMessages getActionMessages(javax.servlet.jsp.PageContext pageContext, java.lang.String paramName) throws javax.servlet.jsp.JspException
- Deprecated. Use TagUtils.getActionMessages(PageContext,String)>
TagUtils.getActionMessages(PageContext,String)55 instead. This will be removed after Struts 1.2.Retrieves the value from request scope and if it isn't already an
ActionMessagessome classes are converted to one.
getActionErrors
public static org.apache.struts.action.ActionErrors getActionErrors(javax.servlet.jsp.PageContext pageContext, java.lang.String paramName) throws javax.servlet.jsp.JspException
- Deprecated. Use TagUtils.getActionErrors(PageContext,String)>
TagUtils.getActionErrors(PageContext,String)55 instead. This will be removed after Struts 1.2.Retrieves the value from request scope and if it isn't already an
ErrorMessagessome classes are converted to one.
encodeURL
public static java.lang.String encodeURL(java.lang.String url)
- Deprecated. Use TagUtils.encodeURL(String)>
TagUtils.encodeURL(String)55 instead. This will be removed after Struts 1.2.Use the new
URLEncoder.encodemethod from Java 1.4 if available, else use the old deprecated version. This method uses reflection to find the appropriate method; if the reflection operations throw exceptions, this will return the url encoded with the oldURLEncoder.encodemethod.
isXhtml
public static boolean isXhtml(javax.servlet.jsp.PageContext pageContext)
- Deprecated. Use TagUtils.isXhtml(PageContext)>
TagUtils.isXhtml(PageContext)55 instead. This will be removed after Struts 1.2.Returns true if the custom tags are in XHTML mode.
- Since:
- Struts 1.1
|
|||||||||
| Home >> All >> org >> apache >> struts >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.struts.util.RequestUtils