Migrate existing Struts applications

Get an overview of how the existing Struts applications can be migrated using the Struts Portlet Framework so that these applications can be deployed in WebSphere Portal.

The Jakarta Struts distribution ships an example Struts application that demonstrates the features of Struts, including implementing Struts Actions, creating custom tags, using the Struts tag libraries, authoring JSPs, and form validation. The Struts Portlet Framework demo builds on this example by incorporating WebSphere Portal features, including support for help mode and WML markup. The Struts example required very few changes to enable it for the Struts Portlet Framework.

The file structure of the WAR file for a Struts Portlet Framework is the same as that used for a Struts servlet. The Struts application in the portal server is a WAR file just like it is in the servlet environment. The portlet WAR file has some additional JARS and other requirements, but the basis of the implementation is similar to the servlet application. See WAR file directory structure for more information.


Migrate servlet-based Struts applications

Existing Struts applications can be migrated using the Struts Portlet Framework so the application can be deployed in WebSphere Portal. Since Struts is a framework there are many variations to how the application can be built with Struts. There are also numerous other frameworks that may also be incorporated into the Struts application. The steps in this section can be used as a starting point for the migration effort, but may not cover all of the issues that can be encountered.

  1. Make sure the existing Struts application has been built as a Struts 1.1 application. (See The Struts Application Framework.)

  2. Check Struts Actions to see if the action writes directly to the response object. If it does then, the action must be modified to either return an ActionForward instead, or check to see if the IStrutsPrepareRender interface should be used.

  3. The Web deployment descriptor must be updated to use the WpsStrutsPortlet as the servlet class instead of the ActionServlet. (See Changes to the Web deployment descriptor.)

  4. The servlet mapping for Struts actions must be specified as the struts-servlet-mapping init parameter. (See Changes to the Web deployment descriptor.)

  5. Create a portlet.xml. The SPFLegacyMailReader.war can be used as an example. (See Portlet deployment descriptor.)

  6. Modify the struts-config.xml to specify the WpsRequestProcessor as the controller. (See Struts configuration file.)

  7. Modify tags that use pageContext.forward() to use the PortletApiUtils forward. (See Forwards and redirects.)

  8. Modify JSPs that use a forward to use the logic forward tag. (See Changes that affect Struts JSPs.)

  9. Modify JSPs as necessary to use the Struts tags for creating URLs, like the Struts Link and Form tags. (See Create portlet URIs).

  10. The JAR files from the WEB_INF/lib directory of the SPFLegacyBlank.war must be used. These files are the Struts JARs and the required Struts Portlet Framework JARs.

  11. The TLD files must be updated from the WEB_INF/lib directory of SPFLegacyBlank.war. Verify the taglib attributes and that the JSP correctly reference the TLD files. This has been a common source of problems when migrating existing applications.

  12. The JSPs should be modified so they do not use html, head and body elements. All HTML output to the portal is written in the context of an HTML table cell.

Refer to the topic, Update portlets built with the Struts Portlet Framework, to determine what level of Struts application is using. You might have to follow some additional migration steps that are described in that topic.


Migrate servlet-based Struts applications to the Standard version

Existing Struts applications can be migrated using the Struts Portlet Framework so the application can be deployed in WebSphere Portal. Since Struts is a framework there are many variations to how the application can be built with Struts. There are also numerous other frameworks that may also be incorporated into the Struts application. The steps in this section can be used as a starting point for the migration effort, but may not cover all of the issues that can be encountered.

  1. Make sure the existing Struts application has been built as a Struts 1.1 application. (See The Struts Application Framework.)

  2. Check Struts Actions to see if the action writes directly to the response object. If it does then, the action must be modified to either return an ActionForward instead, or check to see if the IStrutsPrepareRender interface should be used.

  3. The Web deployment descriptor must be updated to use the StrutsPortlet as the portlet class. Remove the servlet-class from the Web deployment descriptor, and specify the StrutsPortlet as the portlet class in the portlet deployment descriptor. (See Changes to the Web deployment descriptor.)

  4. The servlet mapping for Struts actions must be specified as the struts-servlet-mapping init parameter. The portlets init parameters are specified in the portlet deployment descriptor.

  5. Create a portlet.xml. The SPFStandardMailReader.war can be used as an example. (See Portlet deployment descriptor.)

  6. Modify the struts-config.xml to specify the WpRequestProcessor as the controller. (See Struts configuration file.)

  7. Modify tags that use pageContext.forward() to use the PortletApiUtils forward. (See Forwards and redirects.) The following example illustrates the change in which the PortletApiUtils object is obtained:

    • Old: PortletApiUtils portletUtils = PortletApiUtils.getInstance();

    • New: PortletApiUtils portletUtils = PortletApiUtils.getUtilsInstance();

  8. Modify JSPs that use a forward to use the logic forward tag. (See Changes that affect Struts JSPs.)

  9. Modify JSPs as necessary to use the Struts tags for creating URLs, like the Struts Link and Form tags. (See Create portlet URIs).

  10. The JAR files from the WEB_INF/lib directory of the SPFStandardBlank.war must be used. These files are the Struts JARs and the required Struts Portlet Framework JARs.

  11. The TLD files must be updated from the WEB_INF/lib directory of SPFStandardBlank.war. Verify the taglib attributes and that the JSP correctly reference the TLD files. This has been a common source of problems when migrating existing applications.

  12. The JSPs should be modified so they do not use html, head and body elements. All HTML output to the portal is written in the context of an HTML table cell.


Related information


Parent

Struts Portlet Framework

 


+

Search Tips   |   Advanced Search