Search code examples
javajspservletsstruts-1

How to change the static global variale declared in struts action class


I have global static boolean variable defined in struts-action class. How do i change its value from other Action class.

public class MyAction extends Action{

   public static boolean existsFlag = false;

    public ActionForward execute(ActionMapping mapping,
                            ActionForm actionForm, HttpServletRequest request,
                            HttpServletResponse response)
                    throws Exception
    {
         int a=10;
         if(a==10){
             existsFlag = true; // is this ok to use
         }
         return mapping.findForward("successDisplayForm");
    }

}

Also I have another Action class, where i want to set this value to 'false' when transaction gets completed.

Please help.

Note : Using Struts-1.3


Solution

  • Just like any other public static variable:

    MyAction.existsFlag = true / false;