org.apache.struts.action
public class RequestProcessor extends Object
RequestProcessor contains the processing logic that the {@link ActionServlet} performs as it receives each servlet request from the container. You can customize the request processing behavior by subclassing this class and overriding the method(s) whose behavior you are interested in changing.
Since: Struts 1.1
Version: $Rev: 379703 $ $Date: 2006-02-22 06:17:05 +0000 (Wed, 22 Feb 2006) $
Field Summary | |
---|---|
protected HashMap | actions The set of |
static String | INCLUDE_PATH_INFO The request attribute under which the path information is stored for
processing during a |
static String | INCLUDE_SERVLET_PATH The request attribute under which the servlet path information is stored
for processing during a |
protected static Log | log Commons Logging instance. |
protected ModuleConfig | moduleConfig The |
protected ActionServlet | servlet The servlet with which we are associated. |
Method Summary | |
---|---|
void | destroy() Clean up in preparation for a shutdown of this application. |
protected void | doForward(String uri, HttpServletRequest request, HttpServletResponse response) Do a forward to specified URI using a |
protected void | doInclude(String uri, HttpServletRequest request, HttpServletResponse response) Do an include of specified URI using a |
protected MessageResources | getInternal() Return the |
protected ServletContext | getServletContext() Return the |
void | init(ActionServlet servlet, ModuleConfig moduleConfig) Initialize this request processor instance. |
protected void | internalModuleRelativeForward(String uri, HttpServletRequest request, HttpServletResponse response) Do a module relative forward to specified URI using request dispatcher. |
protected void | internalModuleRelativeInclude(String uri, HttpServletRequest request, HttpServletResponse response) Do a module relative include to specified URI using request dispatcher. |
protected void | log(String message) Log the specified message to the servlet context log for this web application. |
protected void | log(String message, Throwable exception) Log the specified message and exception to the servlet context log for this web application. |
void | process(HttpServletRequest request, HttpServletResponse response) Process an |
protected Action | processActionCreate(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) Return an |
protected ActionForm | processActionForm(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) Retrieve and return the |
protected ActionForward | processActionPerform(HttpServletRequest request, HttpServletResponse response, Action action, ActionForm form, ActionMapping mapping) Ask the specified |
protected void | processCachedMessages(HttpServletRequest request, HttpServletResponse response) Removes any |
protected void | processContent(HttpServletRequest request, HttpServletResponse response) Set the default content type (with optional character encoding) for all responses if requested. |
protected ActionForward | processException(HttpServletRequest request, HttpServletResponse response, Exception exception, ActionForm form, ActionMapping mapping) Ask our exception handler to handle the exception. |
protected boolean | processForward(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) Process a forward requested by this mapping (if any). |
protected void | processForwardConfig(HttpServletRequest request, HttpServletResponse response, ForwardConfig forward) Forward or redirect to the specified destination, by the specified mechanism. |
protected boolean | processInclude(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) Process an include requested by this mapping (if any). |
protected void | processLocale(HttpServletRequest request, HttpServletResponse response) Automatically select a |
protected ActionMapping | processMapping(HttpServletRequest request, HttpServletResponse response, String path) Select the mapping used to process the selection path for this request. |
protected HttpServletRequest | processMultipart(HttpServletRequest request) If this is a multipart request, wrap it with a special wrapper. |
protected void | processNoCache(HttpServletRequest request, HttpServletResponse response) Set the no-cache headers for all responses, if requested. |
protected String | processPath(HttpServletRequest request, HttpServletResponse response) Identify and return the path component (from the request URI) that
we will use to select an |
protected void | processPopulate(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping) Populate the properties of the specified |
protected boolean | processPreprocess(HttpServletRequest request, HttpServletResponse response) General-purpose preprocessing hook that can be overridden as required by subclasses. |
protected boolean | processRoles(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) If this action is protected by security roles, make sure that the current user possesses at least one of them. |
protected boolean | processValidate(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping) If this request was not cancelled, and the request's
{@link ActionMapping} has not disabled validation, call the
|
The set of Action
instances that have been created and
initialized, keyed by the fully qualified Java class name of the
Action
class.
The request attribute under which the path information is stored for
processing during a RequestDispatcher.include
call.
The request attribute under which the servlet path information is stored
for processing during a RequestDispatcher.include
call.
Commons Logging instance.
The ModuleConfiguration
with which we are associated.
The servlet with which we are associated.
Clean up in preparation for a shutdown of this application.
Do a forward to specified URI using a RequestDispatcher
.
This method is used by all internal method needing to do a forward.
Parameters: uri Context-relative URI to forward to request Current page request response Current page response
Since: Struts 1.1
Do an include of specified URI using a RequestDispatcher
.
This method is used by all internal method needing to do an include.
Parameters: uri Context-relative URI to include request Current page request response Current page response
Since: Struts 1.1
Return the MessageResources
instance containing our
internal message strings.
Return the ServletContext
for the web application in which
we are running.
Initialize this request processor instance.
Parameters: servlet The ActionServlet we are associated with moduleConfig The ModuleConfig we are associated with.
Throws: ServletException If an error occor during initialization
Do a module relative forward to specified URI using request dispatcher. URI is relative to the current module. The real URI is compute by prefixing the module name.
This method is used internally and is not part of the public API. It is advised to not use it in subclasses.
Parameters: uri Module-relative URI to forward to request Current page request response Current page response
Since: Struts 1.1
Do a module relative include to specified URI using request dispatcher. URI is relative to the current module. The real URI is compute by prefixing the module name.
This method is used internally and is not part of the public API. It is advised to not use it in subclasses.
Parameters: uri Module-relative URI to include request Current page request response Current page response
Since: Struts 1.1
Deprecated: Use commons-logging instead. This will be removed in a release after Struts 1.2.
Log the specified message to the servlet context log for this web application.
Parameters: message The message to be logged
Deprecated: Use commons-logging instead. This will be removed in a release after Struts 1.2.
Log the specified message and exception to the servlet context log for this web application.
Parameters: message The message to be logged exception The exception to be logged
Process an HttpServletRequest
and create the
corresponding HttpServletResponse
or dispatch
to another resource.
Parameters: request The servlet request we are processing response The servlet response we are creating
Throws: IOException if an input/output error occurs ServletException if a processing exception occurs
Return an Action
instance that will be used to process
the current request, creating a new one if necessary.
Parameters: request The servlet request we are processing response The servlet response we are creating mapping The mapping we are using
Throws: IOException if an input/output error occurs
Retrieve and return the ActionForm
associated with
this mapping, creating and retaining one if necessary. If there is no
ActionForm
associated with this mapping, return
null
.
Parameters: request The servlet request we are processing response The servlet response we are creating mapping The mapping we are using
Ask the specified Action
instance to handle this
request. Return the ActionForward
instance (if any)
returned by the called Action
for further processing.
Parameters: request The servlet request we are processing response The servlet response we are creating action The Action instance to be used form The ActionForm instance to pass to this Action mapping The ActionMapping instance to pass to this Action
Throws: IOException if an input/output error occurs ServletException if a servlet exception occurs
Removes any ActionMessages
object stored in the session
under Globals.MESSAGE_KEY
and Globals.ERROR_KEY
if the messages' isAccessed
method returns true. This
allows messages to be stored in the session, display one time, and be
released here.
Parameters: request The servlet request we are processing. response The servlet response we are creating.
Since: Struts 1.2
Set the default content type (with optional character encoding) for
all responses if requested. NOTE - This header will
be overridden automatically if a
RequestDispatcher.forward
call is
ultimately invoked.
Parameters: request The servlet request we are processing response The servlet response we are creating
Ask our exception handler to handle the exception. Return the
ActionForward
instance (if any) returned by the
called ExceptionHandler
.
Parameters: request The servlet request we are processing response The servlet response we are processing exception The exception being handled form The ActionForm we are processing mapping The ActionMapping we are using
Throws: IOException if an input/output error occurs ServletException if a servlet exception occurs
Process a forward requested by this mapping (if any). Return
true
if standard processing should continue, or
false
if we have already handled this request.
Parameters: request The servlet request we are processing response The servlet response we are creating mapping The ActionMapping we are using
Forward or redirect to the specified destination, by the specified
mechanism. This method uses a ForwardConfig
object instead
an ActionForward
.
Parameters: request The servlet request we are processing response The servlet response we are creating forward The ForwardConfig controlling where we go next
Throws: IOException if an input/output error occurs ServletException if a servlet exception occurs
Process an include requested by this mapping (if any). Return
true
if standard processing should continue, or
false
if we have already handled this request.
Parameters: request The servlet request we are processing response The servlet response we are creating mapping The ActionMapping we are using
Automatically select a Locale
for the current user, if requested.
NOTE - configuring Locale selection will trigger
the creation of a new HttpSession
if necessary.
Parameters: request The servlet request we are processing response The servlet response we are creating
Select the mapping used to process the selection path for this request.
If no mapping can be identified, create an error response and return
null
.
Parameters: request The servlet request we are processing response The servlet response we are creating path The portion of the request URI for selecting a mapping
Throws: IOException if an input/output error occurs
If this is a multipart request, wrap it with a special wrapper. Otherwise, return the request unchanged.
Parameters: request The HttpServletRequest we are processing
Set the no-cache headers for all responses, if requested.
NOTE - This header will be overridden
automatically if a RequestDispatcher.forward
call is
ultimately invoked.
Parameters: request The servlet request we are processing response The servlet response we are creating
Identify and return the path component (from the request URI) that
we will use to select an ActionMapping
with which to dispatch.
If no such path can be identified, create an error response and return
null
.
Parameters: request The servlet request we are processing response The servlet response we are creating
Throws: IOException if an input/output error occurs
Populate the properties of the specified ActionForm
instance from
the request parameters included with this request. In addition,
request attribute Globals.CANCEL_KEY
will be set if
the request was submitted with a button created by
CancelTag
.
Parameters: request The servlet request we are processing response The servlet response we are creating form The ActionForm instance we are populating mapping The ActionMapping we are using
Throws: ServletException if thrown by RequestUtils.populate()
General-purpose preprocessing hook that can be overridden as required
by subclasses. Return true
if you want standard processing
to continue, or false
if the response has already been
completed. The default implementation does nothing.
Parameters: request The servlet request we are processing response The servlet response we are creating
If this action is protected by security roles, make sure that the
current user possesses at least one of them. Return true
to continue normal processing, or false
if an appropriate
response has been created and processing should terminate.
Parameters: request The servlet request we are processing response The servlet response we are creating mapping The mapping we are using
Throws: IOException if an input/output error occurs ServletException if a servlet exception occurs
If this request was not cancelled, and the request's
{@link ActionMapping} has not disabled validation, call the
validate
method of the specified {@link ActionForm},
and forward to the input path if there were any errors.
Return true
if we should continue processing,
or false
if we have already forwarded control back
to the input form.
Parameters: request The servlet request we are processing response The servlet response we are creating form The ActionForm instance we are populating mapping The ActionMapping we are using
Throws: IOException if an input/output error occurs ServletException if a servlet exception occurs InvalidCancelException if a cancellation is attempted without the proper action configuration