| javax.servlet.http.HttpServlet org.apache.struts.action.ActionServlet
All known Subclasses: org.apache.struts.mock.MockActionServlet, org.apache.struts.tiles.RedeployableActionServlet,
ActionServlet | public class ActionServlet extends HttpServlet (Code) | | ActionServlet provides the "controller" in the
Model-View-Controller (MVC) design pattern for web applications that is
commonly known as "Model 2". This nomenclature originated with a
description in the JavaServerPages Specification, version 0.92, and has
persisted ever since (in the absence of a better name).
Generally, a "Model 2" application is architected as follows:
- The user interface will generally be created with server pages, which
will not themselves contain any business logic. These pages represent the
"view" component of an MVC architecture.
- Forms and hyperlinks in the user interface that require business logic
to be executed will be submitted to a request URI that is mapped to this
servlet.
- There can be one instance of this servlet class, which receives
and processes all requests that change the state of a user's interaction
with the application. The servlet delegates the handling of a request to a
RequestProcessor object. This component represents the "controller"
component of an MVC architecture.
- The
RequestProcessor selects and invokes an
Action class to perform the requested business logic, or delegates the response to
another resource.
- The
Action classes can manipulate the state of the
application's interaction with the user, typically by creating or modifying
JavaBeans that are stored as request or session attributes (depending on
how long they need to be available). Such JavaBeans represent the "model"
component of an MVC architecture.
- Instead of producing the next page of the user interface directly,
Action classes generally return an
ActionForward to
indicate which resource should handle the response. If the
Action does not return null, the RequestProcessor
forwards or redirects to the specified resource (by utilizing
RequestDispatcher.forward or Response.sendRedirect )
so as to produce the next page of the user interface.
The standard version of RequestsProcessor implements the
following logic for each incoming HTTP request. You can override some or
all of this functionality by subclassing this object and implementing your
own version of the processing.
- Identify, from the incoming request URI, the substring that will be
used to select an action procedure.
- Use this substring to map to the Java class name of the corresponding
action class (an implementation of the
Action interface).
- If this is the first request for a particular
Action
class, instantiate an instance of that class and cache it for future
use.
- Optionally populate the properties of an
ActionForm bean
associated with this mapping.
- Call the
execute method of this Action class,
passing on a reference to the mapping that was used, the relevant form-bean
(if any), and the request and the response that were passed to the
controller by the servlet container (thereby providing access to any
specialized properties of the mapping itself as well as to the
ServletContext).
The standard version of ActionServlet is configured based
on the following servlet initialization parameters, which you will specify
in the web application deployment descriptor (/WEB-INF/web.xml )
for your application. Subclasses that specialize this servlet are free to
define additional initialization parameters.
- config - Comma-separated list of context-relative
path(s) to the XML resource(s) containing the configuration information for
the default module. (Multiple files support since Struts 1.1)
[/WEB-INF/struts-config.xml].
- config/${module} - Comma-separated list of
Context-relative path(s) to the XML resource(s) containing the
configuration information for the module that will use the specified prefix
(/${module}). This can be repeated as many times as required for multiple
modules. (Since Struts 1.1)
- configFactory - The Java class name of the
ModuleConfigFactory used to create the implementation of the
ModuleConfig interface.
- convertNull - Force simulation of the Struts 1.0
behavior when populating forms. If set to true, the numeric Java wrapper
class types (like
java.lang.Integer ) will default to null
(rather than 0). (Since Struts 1.1) [false]
- rulesets - Comma-delimited list of fully qualified
classnames of additional
org.apache.commons.digester.RuleSet
instances that should be added to the Digester that will be
processing struts-config.xml files. By default, only the
RuleSet for the standard configuration elements is loaded.
(Since Struts 1.1)
- validating - Should we use a validating XML parser to
process the configuration file (strongly recommended)? [true]
- chainConfig - Comma-separated list of either
context-relative or classloader path(s) to load commons-chain catalog
definitions from. If none specified, the default Struts catalog that is
provided with Struts will be used.
version: $Rev: 483039 $ $Date: 2005-10-14 19:54:16 -0400 (Fri, 14 Oct 2005) version: $ |
Method Summary | |
public void | addServletMapping(String servletName, String urlPattern) | public void | destroy() | protected void | destroyConfigDigester() Gracefully release any configDigester instance that we have created. | protected void | destroyInternal() | protected void | destroyModules() | public void | doGet(HttpServletRequest request, HttpServletResponse response) | public void | doPost(HttpServletRequest request, HttpServletResponse response) | public MessageResources | getInternal() | protected ModuleConfig | getModuleConfig(HttpServletRequest request) | protected synchronized RequestProcessor | getRequestProcessor(ModuleConfig config) Look up and return the
RequestProcessor responsible for the
specified module, creating a new one if necessary.
Parameters: config - The module configuration for which to acquire and returna RequestProcessor. | public void | init() Initialize this servlet. | protected void | initChain() | protected Digester | initConfigDigester() | protected void | initInternal() | protected void | initModuleActions(ModuleConfig config) | protected ModuleConfig | initModuleConfig(String prefix, String paths) | protected void | initModuleConfigFactory() | protected void | initModuleExceptionConfigs(ModuleConfig config) | protected void | initModuleFormBeans(ModuleConfig config) | protected void | initModuleForwards(ModuleConfig config) | protected void | initModuleMessageResources(ModuleConfig config) | protected void | initModulePlugIns(ModuleConfig config) | protected void | initModulePrefixes(ServletContext context) Saves a String[] of module prefixes in the ServletContext under
Globals.MODULE_PREFIXES_KEY. | protected void | initOther() | protected void | initServlet() Initialize the servlet mapping under which our controller servlet is
being accessed. | protected void | parseModuleConfigFile(Digester digester, String path) | protected void | parseModuleConfigFile(Digester digester, URL url) | protected void | process(HttpServletRequest request, HttpServletResponse response) | protected ActionConfig | processActionConfigClass(ActionConfig actionConfig, ModuleConfig moduleConfig) Checks if the current actionConfig is using the correct class based
on the class of its ancestor ActionConfig.
Parameters: actionConfig - The action config to check. Parameters: moduleConfig - The config for the current module. | protected void | processActionConfigExtension(ActionConfig actionConfig, ModuleConfig moduleConfig) | protected ExceptionConfig | processExceptionConfigClass(ExceptionConfig exceptionConfig, ModuleConfig moduleConfig, ActionConfig actionConfig) Checks if the current exceptionConfig is using the correct class
based on the class of its configuration ancestor. | protected void | processExceptionExtension(ExceptionConfig exceptionConfig, ModuleConfig moduleConfig, ActionConfig actionConfig) Extend the exception's configuration as necessary. | protected FormBeanConfig | processFormBeanConfigClass(FormBeanConfig beanConfig, ModuleConfig moduleConfig) Checks if the current beanConfig is using the correct class based on
the class of its ancestor form bean config.
Parameters: beanConfig - The form bean to check. Parameters: moduleConfig - The config for the current module. | protected void | processFormBeanExtension(FormBeanConfig beanConfig, ModuleConfig moduleConfig) | protected ForwardConfig | processForwardConfigClass(ForwardConfig forwardConfig, ModuleConfig moduleConfig, ActionConfig actionConfig) Checks if the current forwardConfig is using the correct class based
on the class of its configuration ancestor. | protected void | processForwardExtension(ForwardConfig forwardConfig, ModuleConfig moduleConfig, ActionConfig actionConfig) Extend the forward's configuration as necessary. | protected List | splitAndResolvePaths(String paths) Takes a comma-delimited string and splits it into paths, then
resolves those paths using the ServletContext and appropriate
ClassLoader. |
chainConfig | protected String chainConfig(Code) | | Comma-separated list of context or classloader-relative path(s) that
contain the configuration for the default commons-chain
catalog(s).
|
config | protected String config(Code) | | Comma-separated list of context-relative path(s) to our
configuration resource(s) for the default module.
|
configDigester | protected Digester configDigester(Code) | | The Digester used to produce ModuleConfig objects from a Struts
configuration file.
since: Struts 1.1 |
convertNull | protected boolean convertNull(Code) | | The flag to request backwards-compatible conversions for form bean
properties of the Java wrapper class types.
since: Struts 1.1 |
internalName | protected String internalName(Code) | | The Java base name of our internal resources.
since: Struts 1.1 |
log | protected static Log log(Code) | | Commons Logging instance.
since: Struts 1.1 |
registrations | protected String[] registrations(Code) | | The set of public identifiers, and corresponding resource names, for
the versions of the configuration file DTDs that we know about. There
MUST be an even number of Strings in this list!
|
servletMapping | protected String servletMapping(Code) | | The URL pattern to which we are mapped in our web application
deployment descriptor.
|
servletName | protected String servletName(Code) | | The servlet name under which we are registered in our web
application deployment descriptor.
|
addServletMapping | public void addServletMapping(String servletName, String urlPattern)(Code) | | Remember a servlet mapping from our web application deployment
descriptor, if it is for this servlet.
Parameters: servletName - The name of the servlet being mapped Parameters: urlPattern - The URL pattern to which this servlet is mapped |
destroy | public void destroy()(Code) | | Gracefully shut down this controller servlet, releasing any
resources that were allocated at initialization.
|
destroyConfigDigester | protected void destroyConfigDigester()(Code) | | Gracefully release any configDigester instance that we have created.
since: Struts 1.1 |
destroyInternal | protected void destroyInternal()(Code) | | Gracefully terminate use of the internal MessageResources.
|
destroyModules | protected void destroyModules()(Code) | | Gracefully terminate use of any modules associated with this
application (if any).
since: Struts 1.1 |
getInternal | public MessageResources getInternal()(Code) | | Return the MessageResources instance containing our
internal message strings.
the MessageResources instance containing ourinternal message strings. since: Struts 1.1 |
getModuleConfig | protected ModuleConfig getModuleConfig(HttpServletRequest request)(Code) | | Return the module configuration object for the currently selected
module.
Parameters: request - The servlet request we are processing The module configuration object for the currently selectedmodule. since: Struts 1.1 |
init | public void init() throws ServletException(Code) | | Initialize this servlet. Most of the processing has been factored
into support methods so that you can override particular functionality
at a fairly granular level.
throws: ServletException - if we cannot configure ourselves correctly |
initChain | protected void initChain() throws ServletException(Code) | | Parse the configuration documents specified by the
chainConfig init-param to configure the default
org.apache.commons.chain.Catalog that is registered in the
CatalogFactory instance for this application.
throws: ServletException - if an error occurs. |
initConfigDigester | protected Digester initConfigDigester() throws ServletException(Code) | | Create (if needed) and return a new Digester instance
that has been initialized to process Struts module configuration files
and configure a corresponding ModuleConfig object (which
must be pushed on to the evaluation stack before parsing begins).
A new configured Digester instance. throws: ServletException - if a Digester cannot be configured since: Struts 1.1 |
initModuleActions | protected void initModuleActions(ModuleConfig config) throws ServletException(Code) | | Initialize the action configs for the specified module.
Parameters: config - ModuleConfig information for this module throws: ServletException - if initialization cannot be performed since: Struts 1.3 |
initModuleConfig | protected ModuleConfig initModuleConfig(String prefix, String paths) throws ServletException(Code) | | Initialize the module configuration information for the specified
module.
Parameters: prefix - Module prefix for this module Parameters: paths - Comma-separated list of context-relative resource path(s)for this modules's configuration resource(s) The new module configuration instance. throws: ServletException - if initialization cannot be performed since: Struts 1.1 |
initModuleConfigFactory | protected void initModuleConfigFactory()(Code) | | Initialize the factory used to create the module configuration.
since: Struts 1.2 |
initModuleExceptionConfigs | protected void initModuleExceptionConfigs(ModuleConfig config) throws ServletException(Code) | | Initialize the exception handlers for the specified module.
Parameters: config - ModuleConfig information for this module throws: ServletException - if initialization cannot be performed since: Struts 1.3 |
initModuleFormBeans | protected void initModuleFormBeans(ModuleConfig config) throws ServletException(Code) | | Initialize the form beans for the specified module.
Parameters: config - ModuleConfig information for this module throws: ServletException - if initialization cannot be performed since: Struts 1.3 |
initModuleForwards | protected void initModuleForwards(ModuleConfig config) throws ServletException(Code) | | Initialize the forwards for the specified module.
Parameters: config - ModuleConfig information for this module throws: ServletException - if initialization cannot be performed |
initModuleMessageResources | protected void initModuleMessageResources(ModuleConfig config) throws ServletException(Code) | | Initialize the application MessageResources for the
specified module.
Parameters: config - ModuleConfig information for this module throws: ServletException - if initialization cannot be performed since: Struts 1.1 |
initModulePlugIns | protected void initModulePlugIns(ModuleConfig config) throws ServletException(Code) | | Initialize the plug ins for the specified module.
Parameters: config - ModuleConfig information for this module throws: ServletException - if initialization cannot be performed since: Struts 1.1 |
initModulePrefixes | protected void initModulePrefixes(ServletContext context)(Code) | | Saves a String[] of module prefixes in the ServletContext under
Globals.MODULE_PREFIXES_KEY. NOTE - the "" prefix for
the default module is not included in this list.
Parameters: context - The servlet context. since: Struts 1.2 |
initOther | protected void initOther() throws ServletException(Code) | | Initialize other global characteristics of the controller
servlet.
throws: ServletException - if we cannot initialize these resources |
initServlet | protected void initServlet() throws ServletException(Code) | | Initialize the servlet mapping under which our controller servlet is
being accessed. This will be used in the &html:form>
tag to generate correct destination URLs for form submissions.
throws: ServletException - if error happens while scanning web.xml |
parseModuleConfigFile | protected void parseModuleConfigFile(Digester digester, String path) throws UnavailableException(Code) | | Parses one module config file.
Parameters: digester - Digester instance that does the parsing Parameters: path - The path to the config file to parse. throws: UnavailableException - if file cannot be read or parsed since: Struts 1.2 |
parseModuleConfigFile | protected void parseModuleConfigFile(Digester digester, URL url) throws UnavailableException(Code) | | Parses one module config file.
Parameters: digester - Digester instance that does the parsing Parameters: url - The url to the config file to parse. throws: UnavailableException - if file cannot be read or parsed since: Struts 1.3 |
processActionConfigClass | protected ActionConfig processActionConfigClass(ActionConfig actionConfig, ModuleConfig moduleConfig) throws ServletException(Code) | | Checks if the current actionConfig is using the correct class based
on the class of its ancestor ActionConfig.
Parameters: actionConfig - The action config to check. Parameters: moduleConfig - The config for the current module. The config object using the correct class as determined by theconfig's ancestor and its own overridden value. throws: ServletException - if an instance of the action config classcannot be created. |
processActionConfigExtension | protected void processActionConfigExtension(ActionConfig actionConfig, ModuleConfig moduleConfig) throws ServletException(Code) | | Extend the action's configuration as necessary.
Parameters: actionConfig - the configuration to process. Parameters: moduleConfig - the module configuration for this module. throws: ServletException - if initialization cannot be performed. |
processExceptionConfigClass | protected ExceptionConfig processExceptionConfigClass(ExceptionConfig exceptionConfig, ModuleConfig moduleConfig, ActionConfig actionConfig) throws ServletException(Code) | | Checks if the current exceptionConfig is using the correct class
based on the class of its configuration ancestor. If actionConfig is
provided, then this method will process the exceptionConfig as part
of that actionConfig. If actionConfig is null, the exceptionConfig
will be processed as a global forward.
Parameters: exceptionConfig - The config to check. Parameters: moduleConfig - The config for the current module. Parameters: actionConfig - If applicable, the config for the current action. The exception config using the correct class as determined bythe config's ancestor and its own overridden value. throws: ServletException - if an instance of the exception config classcannot be created. |
processExceptionExtension | protected void processExceptionExtension(ExceptionConfig exceptionConfig, ModuleConfig moduleConfig, ActionConfig actionConfig) throws ServletException(Code) | | Extend the exception's configuration as necessary. If actionConfig is
provided, then this method will process the exceptionConfig as part
of that actionConfig. If actionConfig is null, the exceptionConfig
will be processed as a global forward.
Parameters: exceptionConfig - the configuration to process. Parameters: moduleConfig - the module configuration for this module. Parameters: actionConfig - If applicable, the config for the current action. throws: ServletException - if initialization cannot be performed. |
processFormBeanConfigClass | protected FormBeanConfig processFormBeanConfigClass(FormBeanConfig beanConfig, ModuleConfig moduleConfig) throws ServletException(Code) | | Checks if the current beanConfig is using the correct class based on
the class of its ancestor form bean config.
Parameters: beanConfig - The form bean to check. Parameters: moduleConfig - The config for the current module. The form bean config using the correct class as determined bythe config's ancestor and its own overridden value. throws: UnavailableException - if an instance of the form bean configclass cannot be created. throws: ServletException - on class creation error |
processFormBeanExtension | protected void processFormBeanExtension(FormBeanConfig beanConfig, ModuleConfig moduleConfig) throws ServletException(Code) | | Extend the form bean's configuration as necessary.
Parameters: beanConfig - the configuration to process. Parameters: moduleConfig - the module configuration for this module. throws: ServletException - if initialization cannot be performed. |
processForwardConfigClass | protected ForwardConfig processForwardConfigClass(ForwardConfig forwardConfig, ModuleConfig moduleConfig, ActionConfig actionConfig) throws ServletException(Code) | | Checks if the current forwardConfig is using the correct class based
on the class of its configuration ancestor. If actionConfig is
provided, then this method will process the forwardConfig as part
of that actionConfig. If actionConfig is null, the forwardConfig
will be processed as a global forward.
Parameters: forwardConfig - The forward to check. Parameters: moduleConfig - The config for the current module. Parameters: actionConfig - If applicable, the config for the current action. The forward config using the correct class as determined by theconfig's ancestor and its own overridden value. throws: UnavailableException - if an instance of the forward config classcannot be created. throws: ServletException - on class creation error |
processForwardExtension | protected void processForwardExtension(ForwardConfig forwardConfig, ModuleConfig moduleConfig, ActionConfig actionConfig) throws ServletException(Code) | | Extend the forward's configuration as necessary. If actionConfig is
provided, then this method will process the forwardConfig as part
of that actionConfig. If actionConfig is null, the forwardConfig
will be processed as a global forward.
Parameters: forwardConfig - the configuration to process. Parameters: moduleConfig - the module configuration for this module. Parameters: actionConfig - If applicable, the config for the current action. throws: ServletException - if initialization cannot be performed. |
splitAndResolvePaths | protected List splitAndResolvePaths(String paths) throws ServletException(Code) | | Takes a comma-delimited string and splits it into paths, then
resolves those paths using the ServletContext and appropriate
ClassLoader. When loading from the classloader, multiple resources per
path are supported to support, for example, multiple jars containing
the same named config file.
Parameters: paths - A comma-delimited string of paths A list of resolved URL's for all found resources throws: ServletException - if a servlet exception is thrown |
Methods inherited from javax.servlet.http.HttpServlet | protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc) protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc) protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc) protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc) protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc) protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc) protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc) protected long getLastModified(HttpServletRequest req)(Code)(Java Doc) protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc) public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException(Code)(Java Doc)
|
|
|