Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
HttpServlet
org.apache.struts.action.ActionServlet
public class ActionServlet
extends HttpServlet
RequestDispatcher.forward()
facility of the servlet API
to pass control to an appropriate JSP page to produce the next page
of the user interface.ActionServlet
implements the
following logic for each incoming HTTP request. You can override
some or all of this functionality by subclassing this servlet and
implementing your own version of the processing.
Action
interface).
ActionForm
bean
associated with this mapping.execute
method of this action class, passing
on a reference to the mapping that was used (thereby providing access
to the underlying ActionServlet and ServletContext, as well as any
specialized properties of the mapping itself), and the request and
response that were passed to the controller by the servlet container.
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. Several of these were
deprecated between the 1.0 and 1.1 releases. The deprecated parameters
are listed after the nominal parameters.
java.lang.Integer
) will default to null (rather than 0).
(Since Struts 1.1) [false] 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)MessageResourcesFactory
used to create the application
MessageResources
object.
[org.apache.struts.util.PropertyMessageResourcesFactory]
DEPRECATED - Configure this using the "factory" attribute
of the <message-resources> element.org.apache.struts.action.ActionForward
that defaults the redirect
property to
false
(same as the ActionForward default value).
org.apache.struts.action.ActionForward
that defaults the redirect
property to
true
.
true
, and there is a
user session, identify and store an appropriate
java.util.Locale
object (under the standard key
identified by Globals.LOCALE_KEY
) in the user's session
if there is not a Locale object there already. [true]
DEPRECATED - Configure this using the "locale" attribute of
the <controller> element.org.apache.struts.action.ActionMapping
that
defaults the scope
property to "request".
org.apache.struts.action.ActionMapping
that
defaults the scope
property to "session". (Same
as the ActionMapping default value).
none
, disables Struts multipart
request handling. [org.apache.struts.upload.CommonsMultipartRequestHandler]
DEPRECATED - Configure this using the "multipartClass" attribute of
the <controller> element.true
, add HTTP headers
to every response intended to defeat browser caching of any response we
generate or forward to. [false]
DEPRECATED - Configure this using the "nocache" attribute of
the <controller> element.true
, set our application
resources to return null
if an unknown message key is used.
Otherwise, an error message including the offending message key will
be returned. [true]
DEPRECATED - Configure this using the "null" attribute of
the <message-resources> element.Field Summary | |
protected String |
|
protected Digester |
|
protected boolean |
|
protected FastHashMap |
|
protected int |
|
protected MessageResources |
|
protected String |
|
protected static Log |
|
protected RequestProcessor |
|
protected String[] |
|
protected String |
|
protected String |
|
Method Summary | |
void |
|
private void |
|
private void |
|
private void |
|
private void |
|
private void |
|
void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
void |
|
void |
|
DataSource |
|
ActionFormBean |
|
ActionForward |
|
ActionMapping |
|
protected ApplicationConfig |
|
int |
|
MessageResources |
|
protected ModuleConfig |
|
protected RequestProcessor |
|
MessageResources |
|
private void |
|
void |
|
protected ApplicationConfig |
|
protected void |
|
protected void |
|
protected void |
|
protected Digester |
|
protected void |
|
protected void |
|
protected ModuleConfig |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
void |
|
private void |
|
protected void |
|
protected String config
Comma-separated list of context-relative path(s) to our configuration resource(s) for the default module.
protected Digester configDigester
The Digester used to produce ModuleConfig objects from a Struts configuration file.
- Since:
- Struts 1.1
protected boolean convertNull
The flag to request backwards-compatible conversions for form bean properties of the Java wrapper class types.
- Since:
- Struts 1.1
protected FastHashMap dataSources
The JDBC data sources that has been configured for this module, if any, keyed by the servlet context attribute under which they are stored.
protected int debug
Deprecated.
The debugging detail level for this servlet.
protected String internalName
The Java base name of our internal resources.
- Since:
- Struts 1.1
protected static Log log
Commons Logging instance.
- Since:
- Struts 1.1
protected RequestProcessor processor
TheRequestProcessor
instance we will use to process all incoming requests.
- Since:
- Struts 1.1
protected String[] registrations
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!
protected String servletMapping
The URL pattern to which we are mapped in our web application deployment descriptor. FIXME - multiples???
protected String servletName
The servlet name under which we are registered in our web application deployment descriptor.
public void addServletMapping(String servletName, String urlPattern)
Remember a servlet mapping from our web application deployment descriptor, if it is for this servlet.
- Parameters:
servletName
- The name of the servlet being mappedurlPattern
- The URL pattern to which this servlet is mapped
private void defaultControllerConfig(ModuleConfig config)
Deprecated. Will be removed in a release after Struts 1.1.
Perform backwards-compatible configuration of the default module's controller configuration from servlet initialization parameters (as were used in Struts 1.0).
- Parameters:
config
- The ModuleConfig object for the default module
- Since:
- Struts 1.1
private void defaultFormBeansConfig(ModuleConfig config)
Deprecated. Will be removed in a release after Struts 1.1.
Perform backwards-compatible configuration of an ActionFormBeans collection, and expose it as a servlet context attribute (as was used in Struts 1.0). Note that the current controller code does not (and should not) reference this attribute for any reason.
- Parameters:
config
- The ModuleConfig object for the default app
- Since:
- Struts 1.1
private void defaultForwardsConfig(ModuleConfig config)
Deprecated. Will be removed in a release after Struts 1.1.
Perform backwards-compatible configuration of an ActionForwards collection, and expose it as a servlet context attribute (as was used in Struts 1.0). Note that the current controller code does not (and should not) reference this attribute for any reason.
- Parameters:
config
- The ModuleConfig object for the default app
- Since:
- Struts 1.1
private void defaultMappingsConfig(ModuleConfig config)
Deprecated. Will be removed in a release after Struts 1.1.
Perform backwards-compatible configuration of an ActionMappings collection, and expose it as a servlet context attribute (as was used in Struts 1.0). Note that the current controller code does not (and should not) reference this attribute for any reason.
- Parameters:
config
- The ModuleConfig object for the default app
- Since:
- Struts 1.1
private void defaultMessageResourcesConfig(ModuleConfig config)
Deprecated. Will be removed in a release after Struts 1.1.
Perform backwards-compatible configuration of the default module's message resources configuration from servlet initialization parameters (as were used in Struts 1.0).
- Parameters:
config
- The ModuleConfig object for the default module
- Since:
- Struts 1.1
public void destroy()
Gracefully shut down this controller servlet, releasing any resources that were allocated at initialization.
protected void destroyApplications()
Deprecated. replaced by destroyModules()
Gracefully terminate use of any modules associated with this application (if any).
- Since:
- Struts 1.1
protected void destroyConfigDigester()
Gracefully release any configDigester instance that we have created.
- Since:
- Struts 1.1
protected void destroyDataSources()
Deprecated. Will no longer be required with module support
Gracefully terminate use of the data source associated with this application (if any).
protected void destroyInternal()
Gracefully terminate use of the internal MessageResources.
protected void destroyModules()
Gracefully terminate use of any modules associated with this application (if any).
- Since:
- Struts 1.1
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
Process an HTTP "GET" request.
- Parameters:
request
- The servlet request we are processingresponse
- The servlet response we are creating
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
Process an HTTP "POST" request.
- Parameters:
request
- The servlet request we are processingresponse
- The servlet response we are creating
public DataSource findDataSource(String key)
Deprecated. Look up data sources directly in servlet context attributes
Return a JDBC data source associated with this module, if any.
- Parameters:
key
- The servlet context attribute key under which this data source is stored, ornull
for the default.
public ActionFormBean findFormBean(String name)
Deprecated. Replaced by ModuleConfig.findFormBeanConfig()
Return the form bean definition associated with the specified logical name, if any; otherwise returnnull
.
- Parameters:
name
- Logical name of the requested form bean definition
public ActionForward findForward(String name)
Deprecated. Replaced by ModuleConfig.findForwardConfig()
Return the forwarding associated with the specified logical name, if any; otherwise returnnull
.
- Parameters:
name
- Logical name of the requested forwarding
public ActionMapping findMapping(String path)
Deprecated. Replaced by ModuleConfig.findActionConfig()
Return the ActionMapping for the specified path, for the default module.
- Parameters:
path
- Request path for which a mapping is requested
protected ApplicationConfig getApplicationConfig(HttpServletRequest request)
Deprecated. use
getModuleConfig(HttpServletRequest)
Return the module configuration object for the currently selected module.
- Parameters:
request
- The servlet request we are processing
- Since:
- Struts 1.1
public int getDebug()
Deprecated. Configure the logging detail level in your underlying logging implementation
Return the debugging detail level for this servlet.
public MessageResources getInternal()
Return theMessageResources
instance containing our internal message strings.
- Since:
- Struts 1.1
protected ModuleConfig getModuleConfig(HttpServletRequest request)
Return the module configuration object for the currently selected module.
- Parameters:
request
- The servlet request we are processing
- Since:
- Struts 1.1
protected RequestProcessor getRequestProcessor(ModuleConfig config) throws ServletException
Look up and return theRequestProcessor
responsible for the specified module, creating a new one if necessary.
- Parameters:
config
- The module configuration for which to acquire and return a RequestProcessor.
- Since:
- Struts 1.1
public MessageResources getResources()
Deprecated. Actions should call Action.getResources(HttpServletRequest) instead of this method, in order to retrieve the resources for the current module.
Return the application resources for the default module, if any.
private void handleConfigException(String paths, Exception e) throws UnavailableException
Simplifies exception handling in the parseModuleConfigFile() method.
- Parameters:
paths
-e
-
public void init() throws ServletException
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.
protected ApplicationConfig initApplicationConfig(String prefix, String path) throws ServletException
Deprecated. use
initModuleConfig(String,String)
Initialize the application configuration information for the specified module.
- Parameters:
prefix
- Module prefix for this modulepath
- Context-relative resource path for this modules's configuration resource
- Since:
- Struts 1.1
protected void initApplicationDataSources(ModuleConfig config) throws ServletException
Deprecated. use initModuleDataSources(ModuleConfig)
Initialize the data sources for the specified module.
- Parameters:
config
- ModuleConfig information for this module
- Since:
- Struts 1.1
protected void initApplicationMessageResources(ModuleConfig config) throws ServletException
Deprecated. use initModuleMessageResources()
Initialize the application MessageResources for the specified module.
- Parameters:
config
- ModuleConfig information for this module
- Since:
- Struts 1.1
protected void initApplicationPlugIns(ModuleConfig config) throws ServletException
Deprecated. use
initModulePlugIns(ModuleConfig)
Initialize the plug ins for the specified module.
- Parameters:
config
- ModuleConfig information for this module
- Since:
- Struts 1.1
protected Digester initConfigDigester() throws ServletException
Create (if needed) and return a new Digester instance that has been initialized to process Struts module configuraiton files and configure a corresponding ModuleConfig object (which must be pushed on to the evaluation stack before parsing begins).
- Since:
- Struts 1.1
protected void initDataSources() throws javax.servlet.ServletException
Deprecated. Replaced by initApplicationDataSources() that takes an ModuleConfig argument. This method does nothing.
Initialize data sources for the default module. This method signature is maintained only for backwards compatibility, and will be removed in a subsequent release.
protected void initInternal() throws ServletException
Initialize our internal MessageResources bundle.
protected ModuleConfig initModuleConfig(String prefix, String paths) throws ServletException
Initialize the application configuration information for the specified module.
- Parameters:
prefix
- Module prefix for this modulepaths
- Comma-separated list of context-relative resource path(s) for this modules's configuration resource(s)
- Since:
- Struts 1.1
protected void initModuleDataSources(ModuleConfig config) throws ServletException
Initialize the data sources for the specified module.
- Parameters:
config
- ModuleConfig information for this module
- Since:
- Struts 1.1
protected void initModuleMessageResources(ModuleConfig config) throws ServletException
Initialize the application MessageResources for the specified module.
- Parameters:
config
- ModuleConfig information for this module
- Since:
- Struts 1.1
protected void initModulePlugIns(ModuleConfig config) throws ServletException
Initialize the plug ins for the specified module.
- Parameters:
config
- ModuleConfig information for this module
- Since:
- Struts 1.1
protected void initOther() throws ServletException
Initialize other global characteristics of the controller servlet.
protected void initServlet() throws ServletException
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.
public void log(String message, int level)
Deprecated. Use commons-logging instead.
Log the specified message if the current debugging detail level for this servlet has been set to an equal or higher value. Otherwise, ignore this message.
- Parameters:
message
- Message to be loggedlevel
- Debugging detail level of this message
private void parseModuleConfigFile(String prefix, String paths, ModuleConfig config, Digester digester, String path) throws UnavailableException
Parses one module config file.
- Parameters:
prefix
-paths
-config
-digester
- Digester instance that does the parsingpath
- The path to the config file to parse.
protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
Perform the standard request processing for this request, and create the corresponding response.
- Parameters:
request
- The servlet request we are processingresponse
- The servlet response we are creating