Include Action in struts

Here I am explaining how to do Include Action in struts .

struts-config.xml

<struts-config>

<action-mappings>
<action path="/includetest"
type="org.apache.struts.actions.IncludeAction"
parameter="/Includehello.jsp"
input="/IncludeTest.jsp">
</action>
</action-mappings>
</struts-config>

web.xml

<web-app>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<welcome-file-list>
<welcome-file>IncludeTest.jsp</welcome-file>
</welcome-file-list>

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
</web-app>

IncludeTest.jsp

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<html:html>
<BODY><bR><br><center>
<H2><u>Include Action</H2></u>
<html:link page="/includetest.do">Go to Include Page</html:link>
</html:html>

Includehello.jsp

<br><br><center>
<h2>This Page is Included</h2>

No comments: