Creating Struts portlet JSP files

As is typical when creating other Struts resources, there are two methods to launch the wizard for creating JSP files in a Struts project:

  1. If you use the Web diagram editor, the New JSP File wizard is automatically launched when you realize a Web Page Node that you have dropped on editor's free-form surface from the Web Parts palette drawer. If you plan to use this method, you will need to have the Web diagram (*.gph) file available in the project.

  2. You can also use the standard menu options to access this wizard to create a JSP file outside the context of the Web diagram editor.

The recommended method for creating new Struts portlet JSP files is to design the Struts portlet application using the Web diagram editor, and realize the Web page nodes to launch the New JSP File wizard. When you realize nodes, many of the required values in the wizard are already pre-filled with information based on the node's context in your application. This should simplify the process of creating a JSP file that is accurately-defined for your portlet application.

JSP files created for Struts portlet projects using the New JSP File wizard are compliant in a Portal environment, and have the following characteristics:

  1. Either realize a Web Page node that has a .jsp extension by double-clicking it in a Web diagram (*.gph) file, or select File > New > JSP File from the menu bar. The New JSP File wizard will open.

  2. Specify the appropriate folder for the file. Depending upon the your context in the project, or the method that you used to create the file, this field may be pre-filled.

  3. Type the name of the new JSP file. Optionally, select the Create as JSP Fragment check box to create a JSP fragment that can be included in other JSP files. The appropriate taglib entries will be added to the JSP fragment that you create. If you select the Create from page template option, you can define a consistent look and feel for your portlet pages.

  4. The Markup Language value should be properly pre-selected, based on how the markup and mode was defined when the project that contains the JSP file was created. Struts Portlet JSP should also be pre-selected in the Model field, for the same reason.

  5. Optionally, select the Configure advanced options check box. If you prefer not to configure additional options, click Finish to create the file.

  6. Click Next.

  7. The following default Struts portlet tag library URIs should already be included in the Tag Libraries page: /WEB-INF/struts-html.tld, /WEB-INF/struts-bean.tld, and /WEB-INF/tld/portlet.tld. The location of these TLD files in your project is based on the your project configuration. Click the Add button to locate a TLD file or a JAR file that contains a TLD file to can add tag libraries from a variety of sources.

    Note: If you chose Compact HTML or WML 1.3 as the Markup Language in the previous page of the wizard, manually add the appropriate TLD files in this page of the wizard. These markups are not currently supported by Rational Developer, but you can add the related tag libraries to use the tags available for the specified markups.

  8. Click Next.

  9. Supply any of the encoding, content type, and document type information that you would typically provide for a JSP file. The style sheet options is disabled for portlets. The Document Type value that you select specifies an implicit document type, which is used for content assist, the Properties view, and other editing contexts, when no DOCTYPE declaration is specified in the JSP file. Click Next.

  10. Create init() and destroy() method stubs for the JSP file by selecting the appropriate check boxes, as applicable. Registering the JSP file as a servlet in the Web deployment descriptor is not applicable to portlets, so options related to the Add to web.xml check box should be disabled. If they are enabled, clear the check box to disable them. Click Next.

  11. Click Finish. The JSP file, with appropriate markup, is created and automatically opened in the editing pane.

 

Related concepts

Creating Struts portlets and projects
Web diagrams and the Web diagram editor

 

Related tasks

Creating well-architected Web applications using Struts
Creating Web diagrams for new applications

Related reference
Differences between Struts 1.1 and SPF tag library classes
Struts drawers on the Web tools palette
Properties for Struts tags