Lesson 1.4: Creating an action and an action mapping

Before you begin, you must complete Lesson 1.3: Creating and editing a form bean.

In this Lesson you will create and edit a Struts action mapping.

Creating an action mapping

Create a Struts action and action mapping, as follows:

  1. Open the project's Web diagram.
  2. In the Web diagram editor, double-click the /computeDay action mapping.
  3. On the New Action Mapping page, click Next.
  4. On the Create an Action class for your mapping page, type this text in the Java package field:

    com.ibm.dayofweek

  5. Click Finish.

    An action mapping is added to the Struts configuration file (struts-config.xml), and a file named ComputeDayAction.java is created in DayOfWeek\JavaSource\com\ibm\dayofweek (DayOfWeek > JavaSource > com.ibm.dayofweek in Project Explorer). The ComputeDayAction.java file opens in the Java editor.

Editing the action mapping

  1. Select all of the text in the ComputeDayAction.java file and press Delete.
  2. Copy and paste the contents of the sample code in this popup window into the ComputeDayAction.java file.
  3. Save the file and close it.

    The file ComputeDayAction.java is compiled to produce a ComputeDayAction.class file as shown WebContent > WEB-INF > classes > com > ibm > dayofweek in the Web content folder of the Project Explorer.

  4. Save the Web diagram.

Now you are ready to begin Lesson 1.5: Creating two JSP files.

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.