Share on Google+Share on Google+

Include Tag:

bean:include Tag - is used to load the response from a dynamic application request and make it available as a bean.

Include Tag:


bean:include Tag - is used to load the response from a dynamic application request and make it available as a bean.

This tag performs an internal dispatch to the specified application component (or external URL) and makes the response data available from that request as a bean of type String.

Include  tag works similar to that of the standard <jsp:include> tag, except that the response data is stored in a page scope attribute instead of being written to the output stream. If the current request is part of a session, the generated request for the include  be part of the same session.

Name Description

Optional anchor tag ("#xxx") to be added to the generated hyperlink. Specify this value without any "#" character.


This attribute specifies the logical name of a global ActionForward that contains the actual content-relative URI of the resource to be included.


This attribute specifies the absolute URL (including the appropriate protocol prefix such as "http:") of the resource to be included. Because this URL could be external to the current web application, the session identifier will not be included in the request.


This attribute specifies , the name of the scripting variable (and associated page scope attribute) that will be made available with the value of the specified web application resource.


Page attribute specifies Module-relative URI (starting with a '/') of the web application resource to be included.

Example Illustrating the use of the Include<bean:include> tag.

Here you will learn to use the Struts Html  bean:include tags. 
We will cover an example that will show a working of<bean:include> tags

Example code   :
Creating an Action Class   : Not Required here.
Creating Form Bean    : Not Required here.
Defining the global-forwards    : Not Required here.
Developing the Action Mapping in the struts-config.xml  : Not Required he

Developing the beanIncludeTag.jsp page:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%taglib uri="" prefix="bean" %>
<%taglib uri="" prefix="html" %>
<%taglib uri="" prefix="logic" %>
  <title>Demo Of struts-bean:include Tag</title>
 <body bgcolor="#999933">
  <div align="center">
  <h2><font color="#33FF33">struts-bean:include Tag Demo</font></h2>
  <bean:include id="IncludePageOutput"  page="/IncludePage.jsp" />
  <table border="2">
  <tr><td><p><font color="#33FF33">
  Display the contents returned by invoking

  <pre><bean:write name="IncludePageOutput"/></pre>

Add the following line in the index.jsp to call the form.

<a href="beanIncludeTag.jsp">beanIncludeTagDemo</a><br/>

Building and Testing the Example: 

Build , deploy and Test  the application . 
Open the browser and navigate to the beanIncludeTag.jsp page
Your browser displays the following page beanIncludeTag.jsp and see the output .

Output :

Above actions   displays the working of beanIncludeTag..


Posted on: January 10, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Include Tag:  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image