Creating Struts JSP files
A Struts JavaServer Pages (JSP) file is a JSP file that uses Struts tag libraries. If you select Struts support in the JSP wizard as described below, you can (optionally) create a form in the new JSP file that contains fields from a user-specified form bean.
To create a Struts JSP file:
- In the Project Navigator of the Web perspective, right-click WebContent in a project folder.
- Click New > JSP File.
- Fill out fields on the first New JSP File page, making sure that Struts JSP is specified in the Model field.
- If you want to create the new JSP file with all the defaults, click Finish. The JSP file will contain the two most frequently used Struts tag-library declarations but will not contain a form. If you want to change other information or include a form in the new JSP file, click the Show advanced options box, and then click Next.
- In the Tag libraries box on the Tag Libraries page, select the names of any tag libraries that you want to be added to the new JSP file. If these are the only tag libraries you want, click Next.
- If you want to add other tag libraries, click Add and complete the following actions:
- On the Select a Tag Library page, click the check box for each tag library you want to add, and choose any of the available customizations that you want.
- To specify a tag library that is not in the Tag libraries list, click Import, specify the path name of a JAR file, and click Finish.
- Click OK.
- If you want to remove a tag library from the list on the New JSP File page, select the name of the library and click Remove.
- When the Tag libraries list on the New JSP File page is what you want, click Next.
- On the next two New JSP File pages, provide the information requested, and click Next. For details, see Creating JavaServer Pages (JSP) files.
- If you want to include a form in the new JSP file, complete fields on the Form Field Selection page:
- If your application comprises more than one module and you want to specify a module other than the default, type the path name of the module in the Form bean module field.
- In the Form bean entry field, type the name of the entry or select one from the drop-down list. As you type the entry, the Bean name field is automatically filled out with the same name for the Java bean.
- To specify an action to be invoked by the JSP file, type the name of the action or click Browse.
- If you selected an existing form bean entry and it references an existing ActionForm subclass, the Fields list automatically contains the properties of the ActionForm subclass. You can select which fields you want to include in your form.
- Click Next.
- On the Design the Form page, you can change how the fields are created in the new JSP file:
- Select each field that you want to change. The properties of the selected field will be displayed below, and you can change their values.
- To see nested fields, click on the + icon next to a field. If the selected field is an array, the properties being displayed refer to each array item.
- To change the title of the new JSP file, click the Page tab.
- Click Finish. The JSP file is created, and the JSP editor starts.
- To create custom JSP tags, in the Design view of the JSP editor, click JSP > Insert Custom.
Related concepts
Struts: a framework for developing Web applications
Related tasks
Creating JavaServer Pages (JSP) files
Creating Struts form beans
Related reference
Feedback
Preferences for Struts and Struts development tools