title: Is there any init method given for struts2 action class?
body: <p>Is there any init method provided for struts 2 action class that can be called before every method of that action class?</p>
  
  <p>For example, I have an action class for struts 2 as given below</p>
  
  <pre><code>import com.opensymphony.xwork2.ActionSupport;
  
  public class EmployeeAction extends ActionSupport{
  
      private  DepartmentDaoService deptService = new DepartmentDaoService() ;
      private  EmployeeDaoService empService = new EmployeeDaoService();
      private Employee employee;
      private List&lt;Employee&gt; employees;
      private List&lt;Department&gt; departments;
  
         public void init()
         {
            //Do initialization stuff here
         }
  
         public String getAllEmployees(){
            employees = empService.getAllEmployees();
            return "success";
         }
  
         public String deleteEmployee(){
          empService.deleteEmployee(employee.getEmployeeId());
          return "success";
         }
  }
  </code></pre>
  
  <p>Now in above code when struts action for <code>getAllEmployees()</code> and <code>deleteEmplyee()</code> is called I want <code>init()</code> method to execute first. We can run it by calling it from both functions.</p>
  
  <p>But is there any provision given in struts 2 that will run init method automatically on each call or struts 2 provides any such method for action clases?</p>
  
  <p>Please tell me if anyone knows.</p>
  
  <p>Thanks.</p>