Every portlet WAR must have one portlet.xml file in the WEB-INF directory of the web application. When creating the portlet.xml file, note that:
The Portlet class must be org.apache.struts.action.StrutsPortlet.
The initPage init parameter is mandatory and its value must be the welcome page of the struts application. This can be a direct reference to a JSP file (such as /index.jsp) or it can be a reference of Action Mapping Definition (such as /welcome.do).
The editPage init parameter is not mandatory. If specified, portlet mode EDIT must also be specified in <supports> tag and vice-versa.
The helpPage init parameter is not mandatory. If specified, portlet mode HELP must also be specified in <supports> tag and vice-versa. Note that the help page support is limited to a single page and it can not provide navigation to any other page within struts application.
The factoryName init parameter is mandatory and must be set to com.sun.portal.struts.wrapper.PSServletObjectsFactory.
All the init parameters associated with the ActionServlet as defined in web.xml file must also be configured as init parameter in portlet.xml file.
The URL mapping used for ActionServlet as defined in web.xml file must be configured as an init parameter of the portlet.
Here is a sample portlet.xml file for struts-portlet application:
<?xml version="1.0" encoding="UTF-8"?> <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/portlet/porlet-app_1_0.xsd" version="1.0"> <portlet> <portlet-name>StrutsPortlet</portlet-name> <portlet-class>org.apache.struts.action.StrutsPortlet</portlet-class> <init-param> <name>initPage</name> <value>/index.jsp</value> </init-param> <init-param> <name>helpPage</name> <value>/tour.htm</value> </init-param> <init-param> <name>editPage</name> <value>/edit.jsp</value> </init-param> <init-param> <name>factoryPage</name> <value>com.sun.portal.struts.wrapper.PSServletObjectsFactory</value> </init-param> <init-param> <name>config</name> <value>/WEB-INF/struts-config.xml,/WEB-INF/struts-config-registration.xml</value> </init-param> <init-param> <name>servletPage</name> <value>*.do</value> </init-param> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>HELP</portlet-mode> <portlet-mode>EDIT</portlet-mode> </supports> <portlet-info> <title>StrutsPortlet</title> </portlet-info> </portlet> </portlet-app>