Struts Action

Here you can understand the different actions and helper methods in the Struts Action class. An action is act like an adapter between the incoming HTTP request and take the matched business logic that must be takes the appropriate action. The RequestProcessor is act as the controller of the strut action. It will select needed action for each request then create an instance and call the execute method. The actions must be programmed in a thread safe manner because the RequestProcessor controller will be share the same instance for multiple request.That is we should design with the following items.

1)      Instance and static variables: – It must not be used to store information related to the state of a particular request. Sometimes it used to share global respurces across request for the same action.

2)      Access to other resources (JavaBeans, session variables, etc.):- It must be synchronized if that resource requires protection. Normally the resource classes should be designed to provide their own protection if necessary.

An instance is created the Request Processor controller call setServlet method with non null argument. This helps to identify the servlet instance to which this action is attached. The servlet is to be shutdown or restarted the servlet method will be called with s null argument. This is used to clean up any allocated resources in use by this action.