<div dir="ltr" style="text-align: left;">
<div dir="ltr" style="text-align: left;">In this section, we will discuss about the data tags (generic tags) provided with struts 2 framework .<br />
Struts 2 Data tags, help to get the data from the <b>ValueStack</b>, or place the data into the <b>ValusStack</b>. The Struts 2 data tags are primarily used to manipulate the data displayed on a page.</div>
<h2 dir="ltr" style="text-align: left;"><a href="https://dineshonjava.com/a-tag-example-in-struts2/" target="_blank" rel="noopener"><b>a tag example</b></a></h2>
<div dir="ltr" style="text-align: left;">Struts 2 &#8220;a&#8221; tag is used to render a HTML &#8220;<;a>;&#8221; tag. The best practice is always use &#8220;<;s:url>;&#8221; tag to create the URL and embed it into the &#8220;a&#8221; tag.</p>
<pre class="highlight"><;s:url value="https://dineshonjava.com" var="dojURL" />; 
<;s:a href="%{dojURL}">;Dinesh On Java<;/s:a>; 
</pre>
<p><b><a href="https://dineshonjava.com/a-tag-example-in-struts2/" target="_blank" rel="noopener">Click here for detailed Example.</a></b></p>
<h2><b><a href="https://dineshonjava.com/struts-2-action-tag-example/" target="_blank" rel="noopener">The action tag</a>:</b></h2>
<p>This tag enables developers to call actions directly from a JSP page by specifying the action name and an optional namespace. The body content of the tag is used to render the results from the Action. Any result processor defined for this action in<b> struts.xml</b> will be ignored, unless the <b>executeResult </b>parameter is specified.</p>
<pre class="highlight"><;div>;Tag to execute the action<;/div>; 
<;br />; 
<;s:action name="actionTagAction" executeResult="true" />; 
<;br />; 
<;div>;To invokes special method in action class<;/div>; 
<;br />; 
<;s:action name="actionTagAction!specialMethod" executeResult="true" />; 
</pre>
<p><b><a href="https://dineshonjava.com/struts-2-action-tag-example/" target="_blank" rel="noopener">Click here for detailed Example</a></b>.</p>
<div id="ads-id" align="center"></div>
<h2><b><a href="https://dineshonjava.com/struts-2-include-tag-example/" target="_blank" rel="noopener">The include tag</a>:</b></h2>
<p>In this section, we are going to describe the include tag. The include tag is a generic tag that is used to include a servlet&#8217;s output (result of servlet or a JSP page) to the current page.</p>
<pre class="highlight"><;-- First Syntax -->; 
<;s:include value="dojJsp.jsp" />; 
 
<;-- Second Syntax -->; 
<;s:include value="dojJsp.jsp">; 
 <;s:param name="param1" value="value2" />; 
 <;s:param name="param2" value="value2" />; 
<;/s:include>; 
 
<;-- Third Syntax -->; 
<;s:include value="dojJsp.jsp">; 
 <;s:param name="param1">;value1<;/s:param>; 
 <;s:param name="param2">;value2<;/s:param>; 
<;/s:include>; 
</pre>
<p><b><a href="https://dineshonjava.com/struts-2-include-tag-example/" target="_blank" rel="noopener">Click here for detailed Example</a></b>.</p>
<h2><b><a href="https://dineshonjava.com/in-this-tutorial-we-will-discuss-about/" target="_blank" rel="noopener">The Param Tag</a>:</b></h2>
<p>In this section, we are going to describe the param tag. The param tag is a generic tag that is used to parametrize other tags.<br />
These param tag can be used to parametrize other tags. This tag has the following two parameters.</p>
<ul style="text-align: left;">
<li><b>name </b>(String) &#8211; the name of the parameter</li>
<li><b>value </b>(Object) &#8211; the value of the parameter</li>
</ul>
<pre class="highlight"><;ui:component>; 
 <;ui:param name="username">;Dinesh<;/ui:param>;<;br>; 
 <;ui:param name="username">;Anamika<;/ui:param>;<;br>; 
 <;ui:param name="username">;Sweety<;/ui:param>; 
 <;/ui:component>; 
</pre>
<p><b><a href="https://dineshonjava.com/in-this-tutorial-we-will-discuss-about/" target="_blank" rel="noopener">Click here for detailed Example.</a></b></p>
<h2><b><a href="https://dineshonjava.com/struts-2-set-tag-example/" target="_blank" rel="noopener">The Set Tag</a>:</b></h2>
<p>In this section, we are going to describe the Set tag . The set tag is a generic tag that is used to assign a value to a variable in a specified scope. These set tag assigns a value to a variable in a specified scope. It is useful when you wish to assign a variable to a complex expression and then simply reference that variable each time rather than the complex expression. The scopes available are application, session, request, page and action.</p>
<pre class="highlight"><;h1>;<;span style="background-color: #FFFFcc">;Set Tag 
 (Data Tags) Example!<;/span>;<;/h1>; 
 <;s:set name="technologyName" value="%{'Java'}"/>; 
 Technology Name: <;s:property value="#technologyName"/>; 
</pre>
<p><b><a href="https://dineshonjava.com/struts-2-set-tag-example/" target="_blank" rel="noopener">Click here for detailed Example</a></b>.</p>
<h2><b><a href="https://dineshonjava.com/struts-2-beantag-example/#.Ug4lBm1jxH1" target="_blank" rel="noopener">The bean tag</a>:</b></h2>
<p>These bean tag instantiates a class that conforms to the <b>JavaBeans </b>specification. This tag has a body which can contain a number of Param elements to set any mutator methods on that class. If the var attribute is set on the <b>BeanTag</b>, it will place the instantiated bean into the stack&#8217;s Context.</p>
<pre class="highlight"><;s:bean name="org.apache.struts2.util.Counter" var="counter">; 
 <;s:param name="first" value="20"/>; 
 <;s:param name="last" value="25" />; 
<;/s:bean>; 
</pre>
<p><b><a href="https://dineshonjava.com/struts-2-beantag-example/#.Ug4lBm1jxH1" target="_blank" rel="noopener">Click here for detailed Example</a></b>.</p>
<h2><b><a href="https://dineshonjava.com/struts-2-date-tag-example/" target="_blank" rel="noopener">The date tag</a>:</b></h2>
<p>These date tag will allow you to format a Date in a quick and easy way. You can specify a custom format (eg. <b>&#8220;dd/MM/yyyy hh:mm:ss&#8221;</b>), you can generate easy readable notations (like &#8220;<b>in 3 hours, 14 minutes, 23 seconds</b>&#8220;), or you can just fall back on a predefined format with key &#8216;<b>struts.date.format</b>&#8216; in your properties file.</p>
<pre class="highlight"><;s:date name="user.birthday" format="dd/MM/yyyy" />; 
<;s:date name="user.birthday" format="%{getText('some.i18n.key')}" />; 
<;s:date name="user.birthday" nice="true" />; 
<;s:date name="user.birthday" />; 
</pre>
<p><b><a href="https://dineshonjava.com/struts-2-date-tag-example/" target="_blank" rel="noopener">Click here for detailed Example.</a></b></p>
<h2><b><a href="https://dineshonjava.com/struts-2-property-tag-example/" target="_blank" rel="noopener">The property tag</a>:</b></h2>
<p>These property tag is used to get the property of a value, which will default to the top of the stack if none is specified.</p>
<pre class="highlight"><;s:push value="myBean">; 
 <;!-- Example 1: -->; 
 <;s:property value="myBeanProperty" />; 
 
 <;!-- Example 2: -->;TextUtils 
 <;s:property value="myBeanProperty" default="a default value" />; 
<;/s:push>; 
</pre>
<p><b><a href="https://dineshonjava.com/struts-2-property-tag-example/" target="_blank" rel="noopener">Click here for detailed Example.</a></b></p>
<h2><b><a href="https://dineshonjava.com/struts-2-push-tag-example/" target="_blank" rel="noopener">The push tag</a>:</b></h2>
<p>These push tag is used to push value on stack for simplified usage.</p>
<pre class="highlight"><;s:push value="user">; 
 <;s:propery value="firstName" />; 
 <;s:propery value="lastName" />; 
<;/s:push>; 
</pre>
<p><b><a href="https://dineshonjava.com/struts-2-push-tag-example/" target="_blank" rel="noopener">Click here for detailed Example</a></b>.</p>
<h2><b><a href="https://dineshonjava.com/struts-2-text-tag-example/" target="_blank" rel="noopener">The text tag</a>:</b></h2>
<p>These text tag is used to render a I18n text message.</p>
<pre class="highlight"><;!-- First Example -->; 
<;s:i18n name="struts.action.test.i18n.Shop">; 
 <;s:text name="main.title"/>; 
<;/s:i18n>;</pre>
<pre class="highlight"><;s:text name="main.title" />; 
 
<;s:text name="i18n.label.greetings">; 
 <;s:param >;Mr Smith<;/s:param>; 
<;/s:text>; 
</pre>
<p><b><a href="https://dineshonjava.com/struts-2-text-tag-example/" target="_blank" rel="noopener">Click here for detailed Example.</a></b></p>
<h2><b><a href="https://dineshonjava.com/struts-2-url-tag-example/" target="_blank" rel="noopener">The url tag</a>:</b></h2>
<p>These url tag is used to create a URL.</p>
<pre class="highlight"><;-- Example 1 -->; 
<;s:url value="editGadget.action">; 
 <;s:param name="id" value="%{selected}" />; 
<;/s:url>; 
 
<;-- Example 2 -->; 
<;s:url action="editGadget">; 
 <;s:param name="id" value="%{selected}" />; 
<;/s:url>; 
 
<;-- Example 3-->; 
<;s:url includeParams="get">; 
 <;s:param name="id" value="%{'22'}" />; 
<;/s:url>; 
</pre>
<p><b><a href="https://dineshonjava.com/struts-2-url-tag-example/" target="_blank" rel="noopener">Click here for detailed Example.</a></b></p>
</div>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/struts2-subset-tag-example/">Previous</a> <;<; || <a href="https://dineshonjava.com/struts-2-baby-step-to-learn/">Index </a>|| >;>;<a href="https://dineshonjava.com/a-tag-example-in-struts2/">Next</a> >;>;</b></div>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/struts2-subset-tag-example/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/a-tag-example-in-struts2/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '369'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…