Class RequestProcessor
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ComposableRequestProcessor
RequestProcessor contains the processing logic that the
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$ $Date$
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe set ofActioninstances that have been created and initialized, keyed by the fully qualified Java class name of theActionclass.static final StringThe request attribute under which the path information is stored for processing during aRequestDispatcher.includecall.static final StringThe request attribute under which the servlet path information is stored for processing during aRequestDispatcher.includecall.protected ModuleConfigTheModuleConfigurationwith which we are associated.protected ActionServletThe servlet with which we are associated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Clean up in preparation for a shutdown of this application.protected voiddoForward(String uri, HttpServletRequest request, HttpServletResponse response) Do a forward to specified URI using aRequestDispatcher.protected voiddoInclude(String uri, HttpServletRequest request, HttpServletResponse response) Do an include of specified URI using aRequestDispatcher.protected MessageResourcesReturn theMessageResourcesinstance containing our internal message strings.protected ServletContextReturn theServletContextfor the web application in which we are running.voidinit(ActionServlet servlet, ModuleConfig moduleConfig) Initialize this request processor instance.protected voidinternalModuleRelativeForward(String uri, HttpServletRequest request, HttpServletResponse response) Do a module relative forward to specified URI using request dispatcher.protected voidinternalModuleRelativeInclude(String uri, HttpServletRequest request, HttpServletResponse response) Do a module relative include to specified URI using request dispatcher.voidprocess(HttpServletRequest request, HttpServletResponse response) Process anHttpServletRequestand create the correspondingHttpServletResponseor dispatch to another resource.protected ActionprocessActionCreate(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) Return anActioninstance that will be used to process the current request, creating a new one if necessary.protected ActionFormprocessActionForm(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) Retrieve and return theActionFormassociated with this mapping, creating and retaining one if necessary.protected ActionForwardprocessActionPerform(HttpServletRequest request, HttpServletResponse response, Action action, ActionForm form, ActionMapping mapping) Ask the specifiedActioninstance to handle this request.protected voidprocessCachedMessages(HttpServletRequest request, HttpServletResponse response) Removes anyActionMessagesobject stored in the session underGlobals.MESSAGE_KEYandGlobals.ERROR_KEYif the messages'isAccessedmethod returns true.protected voidprocessContent(HttpServletRequest request, HttpServletResponse response) Set the default content type (with optional character encoding) for all responses if requested.protected ActionForwardprocessException(HttpServletRequest request, HttpServletResponse response, Exception exception, ActionForm form, ActionMapping mapping) Ask our exception handler to handle the exception.protected booleanprocessForward(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) Process a forward requested by this mapping (if any).protected voidprocessForwardConfig(HttpServletRequest request, HttpServletResponse response, ForwardConfig forward) Forward or redirect to the specified destination, by the specified mechanism.protected booleanprocessInclude(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) Process an include requested by this mapping (if any).protected voidprocessLocale(HttpServletRequest request, HttpServletResponse response) Automatically select aLocalefor the current user, if requested.protected ActionMappingprocessMapping(HttpServletRequest request, HttpServletResponse response, String path) Select the mapping used to process the selection path for this request.protected HttpServletRequestprocessMultipart(HttpServletRequest request) If this is a multipart request, wrap it with a special wrapper.protected voidprocessNoCache(HttpServletRequest request, HttpServletResponse response) Set the no-cache headers for all responses, if requested.protected StringprocessPath(HttpServletRequest request, HttpServletResponse response) Identify and return the path component (from the request URI) that we will use to select anActionMappingwith which to dispatch.protected voidprocessPopulate(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping) Populate the properties of the specifiedActionForminstance from the request parameters included with this request.protected booleanprocessPreprocess(HttpServletRequest request, HttpServletResponse response) General-purpose preprocessing hook that can be overridden as required by subclasses.protected booleanprocessRoles(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 booleanprocessValidate(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping) If this request was not cancelled, and the request'sActionMappinghas not disabled validation, call thevalidatemethod of the specifiedActionForm, and forward to the input path if there were any errors.
-
Field Details
-
INCLUDE_PATH_INFO
The request attribute under which the path information is stored for processing during a
RequestDispatcher.includecall.- See Also:
-
INCLUDE_SERVLET_PATH
The request attribute under which the servlet path information is stored for processing during a
RequestDispatcher.includecall.- See Also:
-
actions
The set of
Actioninstances that have been created and initialized, keyed by the fully qualified Java class name of theActionclass. -
moduleConfig
The
ModuleConfigurationwith which we are associated. -
servlet
The servlet with which we are associated.
-
-
Constructor Details
-
RequestProcessor
public RequestProcessor()
-
-
Method Details
-
destroy
public void destroy()Clean up in preparation for a shutdown of this application.
-
init
Initialize this request processor instance.
- Parameters:
servlet- The ActionServlet we are associated withmoduleConfig- The ModuleConfig we are associated with.- Throws:
ServletException- If an error occor during initialization
-
process
public void process(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException Process an
HttpServletRequestand create the correspondingHttpServletResponseor dispatch to another resource.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creating- Throws:
IOException- if an input/output error occursServletException- if a processing exception occurs
-
processActionCreate
protected Action processActionCreate(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) throws IOException Return an
Actioninstance that will be used to process the current request, creating a new one if necessary.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creatingmapping- The mapping we are using- Returns:
- An
Actioninstance that will be used to process the current request. - Throws:
IOException- if an input/output error occurs
-
processActionForm
protected ActionForm processActionForm(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) Retrieve and return the
ActionFormassociated with this mapping, creating and retaining one if necessary. If there is noActionFormassociated with this mapping, returnnull.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creatingmapping- The mapping we are using- Returns:
- The
ActionFormassociated with this mapping.
-
processForwardConfig
protected void processForwardConfig(HttpServletRequest request, HttpServletResponse response, ForwardConfig forward) throws IOException, ServletException Forward or redirect to the specified destination, by the specified mechanism. This method uses a
ForwardConfigobject instead anActionForward.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creatingforward- The ForwardConfig controlling where we go next- Throws:
IOException- if an input/output error occursServletException- if a servlet exception occurs
-
processActionPerform
protected ActionForward processActionPerform(HttpServletRequest request, HttpServletResponse response, Action action, ActionForm form, ActionMapping mapping) throws IOException, ServletException Ask the specified
Actioninstance to handle this request. Return theActionForwardinstance (if any) returned by the calledActionfor further processing.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creatingaction- The Action instance to be usedform- The ActionForm instance to pass to this Actionmapping- The ActionMapping instance to pass to this Action- Returns:
- The
ActionForwardinstance (if any) returned by the calledAction. - Throws:
IOException- if an input/output error occursServletException- if a servlet exception occurs
-
processCachedMessages
Removes any
ActionMessagesobject stored in the session underGlobals.MESSAGE_KEYandGlobals.ERROR_KEYif the messages'isAccessedmethod 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
-
processContent
Set the default content type (with optional character encoding) for all responses if requested. NOTE - This header will be overridden automatically if a
RequestDispatcher.forwardcall is ultimately invoked.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creating
-
processException
protected ActionForward processException(HttpServletRequest request, HttpServletResponse response, Exception exception, ActionForm form, ActionMapping mapping) throws IOException, ServletException Ask our exception handler to handle the exception. Return the
ActionForwardinstance (if any) returned by the calledExceptionHandler.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are processingexception- The exception being handledform- The ActionForm we are processingmapping- The ActionMapping we are using- Returns:
- The
ActionForwardinstance (if any) returned by the calledExceptionHandler. - Throws:
IOException- if an input/output error occursServletException- if a servlet exception occurs
-
processForward
protected boolean processForward(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) throws IOException, ServletException Process a forward requested by this mapping (if any). Return
trueif standard processing should continue, orfalseif we have already handled this request.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creatingmapping- The ActionMapping we are using- Returns:
trueto continue normal processing;falseif a response has been created.- Throws:
IOException- if an input/output error occursServletException- if a servlet exception occurs
-
processInclude
protected boolean processInclude(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) throws IOException, ServletException Process an include requested by this mapping (if any). Return
trueif standard processing should continue, orfalseif we have already handled this request.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creatingmapping- The ActionMapping we are using- Returns:
trueto continue normal processing;falseif a response has been created.- Throws:
IOException- if an input/output error occursServletException- if thrown by invoked methods
-
processLocale
Automatically select a
Localefor the current user, if requested. NOTE - configuring Locale selection will trigger the creation of a newHttpSessionif necessary.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creating
-
processMapping
protected ActionMapping processMapping(HttpServletRequest request, HttpServletResponse response, String path) throws IOException 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 processingresponse- The servlet response we are creatingpath- The portion of the request URI for selecting a mapping- Returns:
- The mapping used to process the selection path for this request.
- Throws:
IOException- if an input/output error occurs
-
processMultipart
If this is a multipart request, wrap it with a special wrapper. Otherwise, return the request unchanged.
- Parameters:
request- The HttpServletRequest we are processing- Returns:
- A wrapped request, if the request is multipart; otherwise the original request.
-
processNoCache
Set the no-cache headers for all responses, if requested. NOTE - This header will be overridden automatically if a
RequestDispatcher.forwardcall is ultimately invoked.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creating
-
processPath
protected String processPath(HttpServletRequest request, HttpServletResponse response) throws IOException Identify and return the path component (from the request URI) that we will use to select an
ActionMappingwith which to dispatch. If no such path can be identified, create an error response and returnnull.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creating- Returns:
- The path that will be used to select an action mapping.
- Throws:
IOException- if an input/output error occurs
-
processPopulate
protected void processPopulate(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping) throws ServletException Populate the properties of the specified
ActionForminstance from the request parameters included with this request. In addition, request attributeGlobals.CANCEL_KEYwill be set if the request was submitted with a button created byCancelTag.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creatingform- The ActionForm instance we are populatingmapping- The ActionMapping we are using- Throws:
ServletException- if thrown by RequestUtils.populate()
-
processPreprocess
General-purpose preprocessing hook that can be overridden as required by subclasses. Return
trueif you want standard processing to continue, orfalseif the response has already been completed. The default implementation does nothing.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creating- Returns:
trueto continue normal processing;falseif a response has been created.
-
processRoles
protected boolean processRoles(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) throws IOException, ServletException If this action is protected by security roles, make sure that the current user possesses at least one of them. Return
trueto continue normal processing, orfalseif an appropriate response has been created and processing should terminate.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creatingmapping- The mapping we are using- Returns:
trueto continue normal processing;falseif a response has been created.- Throws:
IOException- if an input/output error occursServletException- if a servlet exception occurs
-
processValidate
protected boolean processValidate(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping) throws IOException, ServletException, InvalidCancelException If this request was not cancelled, and the request's
ActionMappinghas not disabled validation, call thevalidatemethod of the specifiedActionForm, and forward to the input path if there were any errors. Returntrueif we should continue processing, orfalseif we have already forwarded control back to the input form.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are creatingform- The ActionForm instance we are populatingmapping- The ActionMapping we are using- Returns:
trueto continue normal processing;falseif a response has been created.- Throws:
IOException- if an input/output error occursServletException- if a servlet exception occursInvalidCancelException- if a cancellation is attempted without the proper action configuration.
-
internalModuleRelativeForward
protected void internalModuleRelativeForward(String uri, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException 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 torequest- Current page requestresponse- Current page response- Throws:
IOException- if an input/output error occursServletException- if a servlet exception occurs- Since:
- Struts 1.1
-
internalModuleRelativeInclude
protected void internalModuleRelativeInclude(String uri, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException 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 includerequest- Current page requestresponse- Current page response- Throws:
IOException- if an input/output error occursServletException- if a servlet exception occurs- Since:
- Struts 1.1
-
doForward
protected void doForward(String uri, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException 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 torequest- Current page requestresponse- Current page response- Throws:
IOException- if an input/output error occursServletException- if a servlet exception occurs- Since:
- Struts 1.1
-
doInclude
protected void doInclude(String uri, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException 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 includerequest- Current page requestresponse- Current page response- Throws:
IOException- if an input/output error occursServletException- if a servlet exception occurs- Since:
- Struts 1.1
-
getInternal
Return the
MessageResourcesinstance containing our internal message strings.- Returns:
- The
MessageResourcesinstance containing our internal message strings.
-
getServletContext
Return the
ServletContextfor the web application in which we are running.- Returns:
- The
ServletContextfor the web application.
-