Creating well-architected Web applications using Struts
Struts is a framework for Web application development that can help you create well-architected applications. The Struts tools in this product help make it easier for you to create and test a Struts-based Web application.
Before you create a Struts application, make sure that you are in the Web perspective (see Opening perspectives).
To create and test a Struts application:
- Create a dynamic Web project that has Struts support enabled. (Make sure that the Struts box is checked on the Features page of the New Dynamic Web Project wizard.) If a dynamic Web project exists but does not have Struts support, you can add Struts support.
- Design your Web application.
- If a Web diagram does not exist, create one.
- Edit the Web diagram to create nodes for form beans, Java beans, Web pages, action mappings, Web applications, and Struts modules as appropriate for your application.
- As appropriate for your Struts application, create the following resources by realizing their Web diagram nodes:
You can realize any node in your Web diagram by double-clicking the node and navigating the wizard that is started.
Option Description Form beans See Creating a Struts form bean. Java beans Click File > New > Other > Java > Class. JSP files See Creating JavaServer Pages (JSP) files. On the Form Field Selection page of the New JSP File wizard, specify the module or accept the default. If you have already created the related form bean, the form bean entry is available from the pull-down menu, and the available fields are listed. Check those fields that you want to appear on the JSP page. If you are specifying input fields, check the Generate fields in a form box. If you are specifying output fields, do not check the box. If the box is checked, an ActionForm field appears with a pull-down menu that lists all of the action mappings that are defined in the configuration file for the current module. Select the action mapping that will process your form bean. On the Design the Form page, the fields are supplied automatically from the settings on the previous page. To set the page title, click Page and specify a value for the Page Title property. If you want errors to be displayed when an errors occur in form input, specify true from the pull-down menu for the Show Errors property.
Action mappings See Creating a Struts action mapping. Web applications See Creating a dynamic Web project. Struts modules See Creating a Struts module. Tip: Creating your form beans before the JSP pages that use them eliminates the need to retype the field names when you create the JSP pages.- Edit source and resource files. For example, when you click an Action Mapping node, the wizard the New Action Mapping not only creates an action mapping but also Java source code for the action. You must edit the Java file to contain source code for the application that you are creating.
- Test the application.
- In the Project Navigator, right-click the name of your starting Web page and select Run on Server. A "Server selection" window appears.
- In the Server type field, select the test environment that you want to use, and click Finish. This starts the Web application server and brings up your starting Web page in a browser.
Related concepts
Struts actions and action mappings
Struts form beans
Struts modules
Struts-based Web applications
Related tasks
Opening perspectives
Creating a dynamic Web project
Adding Struts support to dynamic Web projects
Creating Web diagrams
Editing Web application diagrams - overview
Creating Struts actions
Creating Struts form beans
Creating Web pages from Java beans
Creating JavaServer Pages (JSP) files
Creating a simple Struts application
Testing Struts applications
Related reference
Feedback
General preferences for Struts development tools