Create Struts Applications introduction

This tutorial shows you how to create a simple Struts application that has two Web pages, an action mapping, and a form bean. The application contains one Web page that accepts a year, month, and date as input and code that manipulates the data to compute the day of the week. If the input is valid, the computed value is displayed on an output Web page; if the input is not valid, an error message is displayed on the input page.

In this tutorial, you will also learn about building Web applications from Web diagrams. A Web diagram is a file that helps you visualize the application flow of a Faces-based or Struts-based Web application. This picture shows the Web diagram you will create in this tutorial:

An input JSP file, an output JSP file, and a dateData form bean, each connected to a Struts action mapping in the middle

In this figure, index.jsp represents the input JSP file, output.jsp represents the output JSP file, dateData represents the form bean that stores the input and output data, and /computeDay represents a computeDay action mapping of the action code that will be run when an input is submitted and its output is directed to output.jsp. The action code computes the day of the week for a specified date. The following table shows the input and output fields in this application:

Field Name File Name Description
year index.jsp Four-digit year
month index.jsp Two-digit month
day index.jsp Two-digit day
dayOfWeek output.jsp String representing the day of the week

 

 

Time required

To complete this tutorial, you will need approximately 1 hour and 30 minutes. If you decide to explore other facets of Struts applications while working on the tutorial, it could take longer to finish.

 

 

Prerequisites

In order to complete this tutorial, you should be familiar with the following subjects: It will also help if you understand how to do these tasks:

 

 

Learning objectives

This tutorial is divided into several exercises that must be completed in sequence for the tutorial to work properly. This tutorial teaches you how to create a simple Struts application by completing the following exercises:

When you are ready, begin Exercise 1.1: Creating a Struts project