IncludeAction
Previous | Home | Next |
IncludeAction is similar the ForwardAction but only difference is that you need to use the IncludeAction only if the action is going to be included by another jsp.
Used of Include Action :-
1. IncludeAction class to include another resource in the response to the request being processed.
2. IncludeAction class is useful when you want to integrate Struts into an application.Directory Structure of IncludeActionExample in Struts 1.3 Using MyEclipse IDE
index.jsp<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %> <html> <head> <title><bean:message key="label.title"/></title> </head> <body> <h3><bean:message key="label.header"/></h3> <div> <jsp:include page="includePage.jsp"/> </div> </body> </html>web.xml<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>Maven Struts Examples</display-name> <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>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> </web-app>struts-config.xml<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd"> <struts-config> <form-beans/> <global-exceptions /> <global-forwards /> <action-mappings> <action path="/includePage" type="org.apache.struts.actions.IncludeAction" parameter="index.jsp"/> </action-mappings> <message-resources parameter="org.r4r.struts.ApplicationResources" /> </struts-config>ApplicationResources.properties# Resources for parameter 'org.r4r.struts.ApplicationResources' # Project Struts1.3_IncludeActionExample label.title=Struts 1.3 IncludeAction Example label.header=Struts 1.3 IncludeAction Example label.header.include=IncludeAction Page MessageincludePage.jsp<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %> <html> <head> <title><bean:message key="label.title"/></title> </head> <body> <h3><bean:message key="label.header.include"/></h3> <h4>This Message is generated by IncludeAction Example</h4> </body> </html>Output
Previous | Home | Next |