Hi all
   
  I am trying to use struts with netbeans 5.0 but having strange problems.
   
  I have wrtten One ActionForm i.e EmployeeForm ,one action i.e AddEmpAction.
   
  then in the struts-config.xml provided following entries:
   
  <form-bean type="com.myapp.struts.forms.EmployeeForm" name="employee"/>
   
  <action input="/addEmployee.jsp" type="com.myapp.struts.actions.AddEmpAction" 
validate="false" scope="session" path="/addemp" name="employee">
            <forward path="/index.jsp" name="success"/>
</action>
   
  and using /addEmployee.jsp as welcomefile.
   
  But when i run my application it is displaying the addemployee.jsp correctly 
but when i click on the submit button it just displays a blank screen showing 
addemp.do in the address bar.
   
  can anybody provide what i am missing.
   
  the listing of my formbean and action class is following.
   
  import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
  /**
 *
 * @author admin
 */
public class AddEmpAction extends Action{
    
   public ActionForward excecute(ActionMapping mapping,ActionForm 
form,HttpServletRequest request,HttpServletResponse response){
      try{
      System.out.println("inside 
action******************************************");
          EmployeeForm empForm=(EmployeeForm)form;
       String name=empForm.getName();
      float salary=empForm.getSalary();
       String address=empForm.getAddress();
       Employee emp=new Employee(name,salary,address);
       EmployeeDao dao=new EmployeeDao();
       dao.insertEmployee(emp,1);
      
      }
      catch(Exception e){
          e.printStackTrace();
      }
      return mapping.findForward("success");
   }
    
}
   
   
   
   
  /*
 * EmployeeForm.java
 *
 * Created on September 11, 2006, 11:52 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
  package com.myapp.struts.forms;
  import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
  /**
 *
 * @author admin
 */
public class EmployeeForm extends ActionForm {
    private String name;
    private float salary;
    private String address;
  
    public void reset(ActionMapping mapping,HttpServletRequest request){
        setName(null);
        setSalary(0.0F);
        setAddress(null);
    }
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request){
    return null;
}
    public String getName() {
        return name;
    }
      public void setName(String name) {
        this.name = name;
    }
      public float getSalary() {
        return salary;
    }
      public void setSalary(float salary) {
        this.salary = salary;
    }
      public String getAddress() {
        return address;
    }
      public void setAddress(String address) {
        this.address = address;
    }
}
   
   
  thanks
   
  Krishan rathi. 

                
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates 
starting at 1ยข/min.

Reply via email to