struts2.2.1 include tag example.
Posted on: January 6, 2011 at 12:00 AM
In this example, you will see the use of include tag of struts2.2.1.

struts2.2.1 include tag example.

In this example, you will see the use of include tag of struts2.2.1. It is a generic tag that is used to include the output of  html or jsp pages directly into current page or we can include output of another web resource into current page.

Directory structure of include tag example.

 1- index.jsp  ADS_TO_REPLACE_1

<%@taglib prefix="s" uri="/struts-tags" %>

<html>

<head><title>Struts2.2.1_Include_tag_Example</title></head>ADS_TO_REPLACE_2

<body>

<h2>Struts2.2.1_Include_tag_Example</h2>

<hr><s:a href="include.action">Include page</s:a>ADS_TO_REPLACE_3

<hr><s:a href="IncludeTagAction.action">Result page</s:a>

</body>

</html> 

2-IncludeTagAction.java ADS_TO_REPLACE_4

package roseindia.action;

import com.opensymphony.xwork2.ActionSupport;

public class IncludeTagAction extends ActionSupport{ADS_TO_REPLACE_5

private static final long serialVersionUID = 1L;

public String execute() {

return SUCCESS;}ADS_TO_REPLACE_6

}

3-include.jsp

<html>

<head><title>Struts2.2.1_Include_tag_Example</title>ADS_TO_REPLACE_7

<style type="text/css">

.b{color: graytext;} font{color: green;}

</style></head>ADS_TO_REPLACE_8

<body><h2 class="b">Struts2.2.1_Include_tag_Example</h2>

<hr class="b">

<font>Bharat singh<br/> Roseindia Technology </font>ADS_TO_REPLACE_9

</body>

</html>

4_struts.xml

<struts>

<package name="roseindia" extends="struts-default" namespace="/">ADS_TO_REPLACE_10

<action name="IncludeTagAction" class="roseindia.action.IncludeTagAction">

<result>jsp/result.jsp</result>

</action>ADS_TO_REPLACE_11

<action name="include" >

<result>jsp/include.jsp</result>

</action>ADS_TO_REPLACE_12

</package>

</struts>

5_result.jsp

<%@taglib uri="/struts-tags" prefix="s" %>

<html>ADS_TO_REPLACE_13

<head><title>Struts2.2.1_Include_tag_Example</title>

</head>

<body><h2>Struts2.2.1_Include_tag_Example</h2>ADS_TO_REPLACE_14

<hr><h3>Value of include.jsp page</h3>

<s:include value="/jsp/include.jsp"></s:include>

</body>ADS_TO_REPLACE_15

</html>

 

index.jsp

include.jspADS_TO_REPLACE_16

result.jsp

ADS_TO_REPLACE_17

Download Select Source Code


Related Tags for struts2.2.1 include tag example.:

Advertisements

Ads

 
Advertisement null

Ads