Introduction: Use Struts to create a Web application
In this tutorial, you will learn how to create a simple Struts application that contains two Web pages, an action mapping, and a form bean. You will use the Web diagram editor to help you visualize the logic flow of the application. The resulting application displays an input Web page where users can type a year, a month, and a date. If the input is valid, the corresponding day of the week is computed and shown on an output Web page. If the input is invalid, an error message is displayed on the input Web page. You will also learn how to set up a runtime test environment and test your application.
Learning objectives
You will learn how to do these tasks:
- Create a Struts project
- Edit your Web diagram
- Create and edit a form bean
- Create input and output JSP files
- Create an action and an action mapping
- Add ActionError tags to the input JSP page
- Test your Struts application
Time Required
This tutorial should take approximately 60 minutes to finish. If you explore other concepts related to this tutorial, it could take longer to complete.
Skill level
Advanced
Audience
Web application developers and Web user interface designers
System requirements
To complete this tutorial, you need one of the following servers configured on your local machine:
- WAS v7.0
- WAS 6.x
- WAS 5.1 test environment or remote server
- An Apache Tomcat 5.x runtime server
To complete this tutorial, install Struts Tools. To install Struts Tools, in Installation Manager, click...
Modify | Features list | Struts Tools | Modify
Prerequisites
To complete this tutorial, you should be familiar with the following areas:
- Basic Web design concepts, such as sites, pages, browsers, and servers
- Web page elements, such as tables, hyperlinks, forms, and images
- Editing HTML code for Web pages
- Workbench perspectives and views in Eclipse-based products
Lessons in this tutorial
- Lesson 1: Create a Struts enabled Web project
Use this lesson to learn how to create a dynamic Web project that is enabled for Struts.- Lesson 2: Create Web diagram nodes
Use this lesson to learn how to add nodes to the Web diagram of your new project.- Lesson 3: Create a form bean
Use this lesson to learn how to create a form bean.- Lesson 4: Connect nodes in the Web diagram
Use this lesson to learn how to use connection handles to connect the nodes in your Web diagram.- Lesson 5: Edit a form bean
Use this lesson to learn how to edit the form bean source file and the Java™ resource file so that they work correctly in your Struts application.- Lesson 6: Edit an action mapping
Use this lesson to learn how an action mapping represents an action that is run, and when running, it determines the flow of the application.- Lesson 7: Add elements to JSPs
Use this lesson to learn how to add input fields, push buttons, and output fields to JSP pages to create dynamic user interfaces for input and output.- Lesson 8: Display error messages
Use this lesson to learn how to display error messages when an action returns them to the input JSP page.- Lesson 9: Test a Struts application
Use this lesson to learn how to test your Struts application in an IBM® WebSphere or Apache Tomcat runtime environment. You should be able to see the input and output controls that you previously added to the JSP pages in this environment.