1. Now create a new Java class. This class will be the main data bean for this project.
    1. Right click on src, and select New => Class
    2. For the name, call it PersonalData.
    3. For the package, put in "pdata."
    4. Select Finish

    NOTE: By convention, Class names begin with an upper case letter, and package names begin with a lowercase letter.

    New Java Class dialog box in Eclipse
  2. Create another class and name it PersonalDataAction with the same package name, and save it. This class will be the main Struts action for this project.
  3. Create one more class, and name it Constants. This class will hold global constants for the project.
  4. Setup libraries for the project
    1. Right click the project name and select Properties
    2. Select the Libraries tab and then Add External Jars
    3. Navigate to Tomcat Home/common/lib
    4. Select servlet-api.jar and jsp-api.jar, Click Open.
    5. Select Add Jars, and select struts-core-1.3.5.jar from WebRoot/WEB-INF/lib, Click OK.
  5. Implement the PersonalData bean
    1. Add necessary imports
      import org.apache.struts.action.ActionForm;
      import java.io.Serializable;
    2. Change inheritance
      1. Add extends ActionForm
      2. Add implements Serializable
    3. Add member variables. These will correspond to the form we implement in JSP later. private String firstname;
      private String lastname ;
      private String address ;
      private String city ;
      private String state ;
    4. Add the getters and setters for the class members.
      1. By hand, you would add a get method and a set method for each member variable. For more information on this, look up standard naming conventions and methods for Java Beans.
      2. In Eclipse, you can right click on the edit area, and select Source => Generate Getters and Setters. Generate Getters and Setters Dialog in Eclipse
    5. Select all member variables and hit OK.
      Generating Getters and Setters in Eclipse
    6. Save File
  6. Implement the Constants class
    1. Create a constant for success and failures of a Struts action public static final String SUCCESS_KEY = "success";
      public static final String FAILURE_KEY = "failure";
    2. Save File
      NOTE: By convention, static finals are in all upper case.
Page 1 Page 3 Page 4