package untitled3;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.Action;

public class addAction
    extends Action {
  public ActionForward execute(ActionMapping actionMapping,
                               ActionForm actionForm,
                               HttpServletRequest servletRequest,
                               HttpServletResponse servletResponse) {
    addActionForm addActionForm = (addActionForm) actionForm;
         String num1 = addActionForm.getNum1();
         String num2 = addActionForm.getNum2();
         if (num1.length() >= 0 && num2.length() >=0) {
                    float num3=Float.parseFloat(num1.trim())+ Float.parseFloat(num2.trim());
                    servletRequest.setAttribute("result",new Float(num3));
             return actionMapping.findForward("success");
         }
         else
             return null;
     }

}
