Your First Cup: An Introduction to the Java EE Platform

ProcedureGetting the Age Difference From the DukesBirthdayBean Enterprise Bean

During this task, you will create a processBirthday method to get the difference in age between the user's age and Duke's age from the EJB, set the absAgeDiff variable to the absolute value of the age difference, and set a result string that is will forward the user to the display page..

  1. Add a processBirthday method with the following code:

        public String processBirthday() {
  "age diff from dukesbday " + ageDiff);
  "absAgeDiff " + absAgeDiff);
            return new String("success");

    This method calls the getAgeDifference method of DukesBirthdayBean to get the age difference and store it in the ageDiff property, sets the absolute age difference stored in the absAgeDiff property, and returns a status code of success. This status code will be used by the JavaServer Faces runtime to forward the user to the appropriate page.

  2. Right-click in the editor window and select Format.

  3. Select File -> Save.