<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JavaBeat &#187; Struts</title>
	<atom:link href="http://www.javabeat.net/category/web-frameworks/struts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javabeat.net</link>
	<description>Java Technology News</description>
	<lastBuildDate>Mon, 13 May 2013 20:10:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Struts LOGIC messagesPresent and messagesNotPresent Tag ( &lt; logic:messagesPresent &gt;  and &lt; logic:messagesNotPresent &gt;)</title>
		<link>http://www.javabeat.net/2010/10/struts-logic-messagespresent-and-messagesnotpresent-tag-logicmessagespresent-and-logicmessagesnotpresent/</link>
		<comments>http://www.javabeat.net/2010/10/struts-logic-messagespresent-and-messagesnotpresent-tag-logicmessagespresent-and-logicmessagesnotpresent/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 03:14:57 +0000</pubDate>
		<dc:creator>AbhilashEtikala</dc:creator>
				<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=466</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Struts LOGIC Tag Library Struts LOGIC tag library provides tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. Read Integrating Struts With Spring Syntax to use Struts LOGIC tag library 1 &#60;code&#62;&#38;amp;lt%@ taglib prefix=&#34;logic&#34; uri=&#34;http://struts.apache.org/tags-logic&#34; %&#38;amp;gt &#38;lt logic:messagesPresent &#38;gt [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><a id="dd_start"></a><h2>Struts LOGIC Tag Library</h2>
<p>Struts <b>LOGIC tag library</b> provides tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. </p>
<ul>
<li>Read <a href="http://www.javabeat.net/articles/70-integrating-struts-with-spring-1.html">Integrating Struts With Spring</a></li>
</ul>
<h2>Syntax to use Struts LOGIC  tag library</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">	&lt;code&gt;&amp;amp;lt%@ taglib prefix=&quot;logic&quot; uri=&quot;http://struts.apache.org/tags-logic&quot; %&amp;amp;gt</pre></td></tr></table></div>

<h2>&amp;lt logic:messagesPresent &amp;gt and &amp;lt logic:messagesNotPresent&amp;gt</h2>
<p><b>&amp;lt logic:messagesPresent &amp;gt	</b>-This tag is used if an <i>ActionMessages object, ActionErrors object, a String, or a String array</i> is <b>present</b> in any scope the nested body content of this tag is evaluated.  </p>
<p><b>&amp;lt logic:messagesNotPresent &amp;gt	</b>- This tag is used if an <i>ActionMessages object, ActionErrors object, a String, or a String array</i> is <b>not present</b> in any scope the nested body content of this tag is evaluated.</p>
<p>By default both the tags will retrieve the bean it will iterate over from the Globals.ERROR_KEY constant string, but if <i>message</i> attribute is set to &#8216;true&#8217; the bean will be retrieved from the Globals.MESSAGE_KEY constant string.If <i>message</i> attribute  is set to &#8216;true&#8217;, any value assigned to the name attribute will be ignored.</p>
<h2>Example Code for &amp;lt logic:messagesPresent &amp;gt and &amp;lt logic:messagesNotPresent&amp;gt</h2>
<p>1.Create of Modify the <b>index.jsp page</b> which is the welcome page for the users.It forwards to the action class.</p>
<p><b>index.jsp</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&amp;lt;%@page contentType=&quot;text/html&quot;%&amp;gt;
&amp;lt;%@page pageEncoding=&quot;UTF-8&quot;%&amp;gt;
&nbsp;
&amp;lt;jsp:forward page=&quot;logicmessage.do&quot;/&amp;gt;</pre></td></tr></table></div>

<p>2.Create an Jsp page and name it as <b>LogicMessageTag.jsp</b>.It is the output page for user which contains the logic tags to to check whether the page contains any error messages or not.</p>
<p><b>LogicMessageTag.jsp</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&amp;lt;%@page contentType=&quot;text/html&quot; pageEncoding=&quot;UTF-8&quot;%&amp;gt;
&amp;lt;%@taglib  uri=&quot;http://struts.apache.org/tags-logic&quot; prefix=&quot;logic&quot; %&amp;gt;
&amp;lt;%@taglib uri=&quot;http://struts.apache.org/tags-bean&quot; prefix=&quot;bean&quot; %&amp;gt;
&nbsp;
&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&amp;gt;
        &amp;lt;title&amp;gt;Struts Logic Message Present not Present Tag&amp;lt;/title&amp;gt;
    &amp;lt;/head&amp;gt;
    &amp;lt;body bgcolor=&quot;DDDDDD&quot;&amp;gt;
        &amp;lt;h1&amp;gt;struts logic:messagesPresent and logic:messagesNotPresent tag&amp;lt;/h1&amp;gt;
        &amp;lt;logic:messagesPresent &amp;gt;
	&amp;lt;h4&amp;gt;There are errors on this page!
    The error message is
    &amp;lt;bean:message key=&quot;common.errors.text&quot;/&amp;gt;
    &amp;lt;/h4&amp;gt;
&amp;lt;/logic:messagesPresent&amp;gt;
&amp;lt;logic:messagesNotPresent message=&quot;true&quot;&amp;gt;
    &amp;lt;h4&amp;gt;There are no errors messages on this page!&amp;lt;/h4&amp;gt;
&amp;lt;/logic:messagesNotPresent&amp;gt;
&nbsp;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;</pre></td></tr></table></div>

<p>3.Create a Form bean.Form bean is used to hold the properties of the submitted form which is a sub class of ActionForm.It contains only one property of type String to hold the text.This form contains the validate method to add error messages to the request page.</p>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<p>.
	</ul>
</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p><b>LogicMessageForm.java</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
&nbsp;
public class LogicMessageForm extends org.apache.struts.action.ActionForm {
&nbsp;
    private String text;
&nbsp;
    public String getText() {
        return text;
    }
&nbsp;
    public void setText(String text) {
        this.text = text;
    }
&nbsp;
&nbsp;
    public LogicMessageForm() {
        super();
&nbsp;
    }
&nbsp;
&nbsp;
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
&nbsp;
         ActionErrors errors = new ActionErrors();
&nbsp;
	   errors.add(&quot;common.errors.text&quot;,
		new ActionMessage(&quot;common.errors.text&quot;));
        return errors;
    }
}</pre></td></tr></table></div>

<p>4.<b>ApplicationResource.properties</b> file contains the messages and their corresponding keys.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">common.errors.text=Text Required</pre></td></tr></table></div>

<p>5.Simple Action class <b>LogicMessageAction.java</b> which is a sub class of <i>Action</i> class used to process the user&#8217;s request. </p>
<p><b>LogicMessageAction.java</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
&nbsp;
public class LogicMessageAction extends org.apache.struts.action.Action {
&nbsp;
&nbsp;
    private final static String SUCCESS = &quot;success&quot;;
&nbsp;
&nbsp;
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
&nbsp;
        return mapping.findForward(SUCCESS);
    }
}</pre></td></tr></table></div>

<p>6.Create or modify struts config file <b>struts-config.xml</b> with action mappings.Struts-config file contains the information about the configuration of the struts framework to the application.It contains the action mappings which helps to select Action,ActionForm and other information for specific user&#8217;s request&#8217;s.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&nbsp;
&amp;amp;lt?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&amp;amp;gt
&nbsp;
&amp;amp;lt!DOCTYPE struts-config PUBLIC
          &quot;-//Apache Software Foundation//DTD Struts Configuration 1.2//EN&quot;
          &quot;http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd&quot;&amp;amp;gt
&nbsp;
&amp;amp;lt struts-config&amp;amp;gt
    &amp;amp;lt form-beans&amp;amp;gt
        &amp;amp;lt form-bean name=&quot;LogicMessageForm&quot; type=&quot;com.myapp.struts.LogicMessageForm&quot;/&amp;amp;gt
    &amp;amp;lt/form-beans&amp;amp;gt
&nbsp;
&amp;amp;lt action-mappings&amp;amp;gt
        &amp;amp;lt action input=&quot;/LogicMessageTag.jsp&quot; name=&quot;LogicMessageForm&quot; path=&quot;/logicmessage&quot; scope=&quot;request&quot; validate=&quot;true&quot; type=&quot;com.myapp.struts.LogicMessageAction&quot;&amp;amp;gt
        &amp;amp;lt forward name=&quot;success&quot; path=&quot;/LogicMessageTag.jsp&quot;/&amp;amp;gt
&nbsp;
            &amp;amp;lt/action&amp;amp;gt
&amp;amp;lt/action-mappings&amp;amp;gt
     &amp;lt;message-resources parameter=&quot;com/myapp/struts/ApplicationResource&quot;/&amp;gt;
	&amp;amp;lt/struts-config&amp;amp;gt</pre></td></tr></table></div>

<p>7.Building and running the application</p>
<h4><b>Output</b></h4>
<p><b>Access page:
<pre><code>http://localhost:8080/logicmessage/</code></pre>
<p></b></p>
<p><img src="images/2010/10/struts-logicmessage/struts-logicmessage-1.jpg" width="585" height="204"></p>
<h2>Struts Framework Articles</h2>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<li><a href="http://www.javabeat.net/articles/67-struts-20-introduction-and-validations-using-annotatio-1.html">Struts 2.0 Introduction and Validations using Annotations</a></li>
<li><a href="http://www.javabeat.net/articles/24-introduction-to-struts-actions-1.html">Introduction to Struts Actions</a></li>
<li><a href="http://www.javabeat.net/articles/69-whats-new-in-struts-20-struts-20-framework-1.html">What&#8217;s new in Struts 2.0?</a></li>
<li><a href="http://www.javabeat.net/articles/132-internationalization-and-taglibs-in-struts-12-1.html">Internationalization and Taglibs in Struts 1.2</a></li>
<p>	</u></p>
<div class='dd_outer'><div class='dd_inner'><div id='dd_ajax_float'><div class='dd_button_v'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Fwww.javabeat.net%2Fcategory%2Fweb-frameworks%2Fstruts%2Ffeed%2F" send="false" show_faces="false"  layout="box_count" width="50"  ></fb:like></div><div style='clear:left'></div><div class='dd_button_v'><script type='text/javascript' src='https://apis.google.com/js/plusone.js'></script><g:plusone size='tall' href='http://www.javabeat.net/category/web-frameworks/struts/feed/'></g:plusone></div><div style='clear:left'></div><div class='dd_button_v'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.javabeat.net/category/web-frameworks/struts/feed/" data-count="vertical" data-text="Struts" data-via="javabeat" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style='clear:left'></div><div class='dd_button_extra_v'><script type="text/javascript">jQuery(document).load(function(){ stLight.options({publisher:'bab47279-62c9-46af-addc-79fd1fe8fee0'}); });</script><div class="st_email_custom"><span id='dd_email_text'>email</span></div></div><div style='clear:left'></div><div class='dd_button_extra_v'><div id='dd_print_button'><span id='dd_print_text'><a href='javascript:window:print()'>print</a></span></div></div><div style='clear:left'></div></div></div></div><script type="text/javascript">var dd_offset_from_content = 44; var dd_top_offset_from_content = 0;</script><script type="text/javascript" src="http://www.javabeat.net/wp-content/plugins/digg-digg//js/diggdigg-floating-bar.js?ver=5.3.0"></script><div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/10/struts-logic-messagespresent-and-messagesnotpresent-tag-logicmessagespresent-and-logicmessagesnotpresent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts LOGIC match and notMatch Tag ( &lt; logic:match &gt;  and &lt; logic:notMatch &gt;)</title>
		<link>http://www.javabeat.net/2010/10/struts-logic-match-and-notmatch-tag-logicmatch-and-logicnotmatch/</link>
		<comments>http://www.javabeat.net/2010/10/struts-logic-match-and-notmatch-tag-logicmatch-and-logicnotmatch/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 03:14:21 +0000</pubDate>
		<dc:creator>AbhilashEtikala</dc:creator>
				<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=464</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Struts LOGIC match and notMatch Tag ( &#60; logic:match &#62; and &#60; logic:notMatch &#62;) Struts LOGIC Tag Library Struts LOGIC tag library provides tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. Read Integrating Struts With Spring Syntax to [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h1>Struts LOGIC match and notMatch Tag ( &lt; logic:match &gt;  and &lt; logic:notMatch &gt;) </h1>
<h2>Struts LOGIC Tag Library</h2>
<p>Struts <b>LOGIC tag library</b> provides tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. </p>
<ul>
<li>Read <a href="http://www.javabeat.net/articles/70-integrating-struts-with-spring-1.html">Integrating Struts With Spring</a></li>
</ul>
<h2>Syntax to use Struts LOGIC  tag library</h2>
<pre>
	<code>&amp;lt%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %&amp;gt</code>
</pre>
<h2>&amp;lt logic:match &amp;gt and &amp;lt logic:notMatch&amp;gt</h2>
<p><b>&amp;lt logic:match &amp;gt	</b>-This tag matches the selector attributes(String) by specified constant variable.If the value <b>is a substring</b> (appropriately limited by the <i>location</i> attribute), the nested body content of this tag is evaluated  </p>
<p><b>&amp;lt logic:notMatch &amp;gt	</b>- This tag macthes between the selector attributes(String) by specified constant variable. If the value <b>is not a substring</b> (appropriately limited by the <i>location</i> attribute), the nested body content of this tag is evaluated.</p>
<h2>Example Code for &amp;lt logic:match &amp;gt and &amp;lt logic:notMatch&amp;gt</h2>
<p>1.Create of Modify the <b>index.jsp page</b> whic is the welcome page for the users.It displays a Textbox nested inside the form where the text is to be entered.</p>
<p><b>index.jsp</b></p>
<pre><code>
&amp;lt %@page contentType="text/html" pageEncoding="UTF-8"%&amp;gt
&amp;lt %@taglib  uri="http://struts.apache.org/tags-html" prefix="html" %&amp;gt
&amp;lt !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd"&amp;gt

&amp;lt html&amp;gt
    &amp;lt head&amp;gt
        &amp;lt meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&amp;gt
        &amp;lt title&amp;gt Struts Match Tag Example&amp;lt /title&amp;gt
    &amp;lt /head&amp;gt
    &amp;lt body bgcolor="DDDDDD"&amp;gt

        &amp;lt html:form action="/logicmatch"&amp;gt
        &amp;lt h3&amp;gt Enter Some Text:&amp;lt /h3&amp;gt
        &amp;lt html:text name="LogicMatchForm" property="text"/&amp;gt
        &amp;lt html:submit/&amp;gt


        &amp;lt /html:form&amp;gt
    &amp;lt /body&amp;gt
&amp;lt /html&amp;gt
</code></pre>
<p>2.Create an Jsp page and name it as <b>LogicMatchTag.jsp</b>.It is the output page for user which contains the logic tags to Match the text and display whether the specified constant value is a substring or not.</p>
<p><b>LogicMatchTag.jsp</b></p>
<pre><code>
&amp;lt%@page contentType="text/html" pageEncoding="UTF-8"%&amp;gt
&amp;lt%@taglib prefix="html" uri="http://jakarta.apache.org/struts/tags-html" %&amp;gt
&amp;lt%@taglib prefix="logic" uri="http://jakarta.apache.org/struts/tags-logic" %&amp;gt


&amp;lt html&amp;gt
    &amp;lt head&amp;gt
        &amp;lt meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&amp;gt
        &amp;lt title&amp;gt Struts Logic Match Tag&amp;lt /title&amp;gt
    &amp;lt /head&amp;gt
    &amp;lt body bgcolor="DDDDDD"&amp;gt
        &amp;lt h1&gt;Struts logic:match and logic:notMatch tag&amp;lt /h1&amp;gt
        &amp;lt logic:match name="LogicMatchForm" property="text" value="java&amp;gt
&amp;lt h4&amp;gt Using &lt;logic:match&gt; tag the given text contains "java"&amp;lt /h4&amp;gt

            &amp;lt /logic:match&amp;gt
            &amp;ltlogic:notMatch name="LogicMatchForm" property="text" value="struts"&amp;gt
&amp;lt h4&amp;gt  Using &lt;logic:notMatch&gt; tag the given text does not contains "struts"&amp;lt /h4&amp;gt

            &amp;lt /logic:notMatch&amp;gt
    &amp;lt /body&amp;gt
&amp;lt /html&amp;gt

</code></pre>
<p>3.Create a Form bean.Form bean is used to hold the properties of the submitted form which is a sub class of ActionForm.It contains only one property of type String to hold the text.</p>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<p>.
	</ul>
</p>
<p><b>LogicMatchForm.java</b></p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<pre><code>
package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LogicMatchForm extends org.apache.struts.action.ActionForm {

    private String text;

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public LogicMatchForm() {
        super();

    }

}

</code></pre>
<p>4.Simple Action class <b>LogicMatchAction.java</b> which is a sub class of <i>Action</i> class used to process the user&#8217;s request. </p>
<p><b>LogicMatchAction.java</b></p>
<pre><code>
package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

public class LogicMatchAction extends org.apache.struts.action.Action {


    private final static String SUCCESS = "success";

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        return mapping.findForward(SUCCESS);
    }
}


</code></pre>
<p>5.Create or modify struts config file <b>struts-config.xml</b> with action mappings.Struts-config file contains the information about the configuration of the struts framework to the application.It contains the action mappings which helps to select Action,ActionForm and other information for specific user&#8217;s request&#8217;s.</p>
<pre><code>

&amp;lt?xml version="1.0" encoding="UTF-8" ?&amp;gt

&amp;lt!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"&amp;gt

&amp;lt struts-config&amp;gt
    &amp;lt form-beans&amp;gt
        &amp;lt form-bean name="LogicMatchForm" type="com.myapp.struts.LogicMatchForm"/&amp;gt
    &amp;lt/form-beans&amp;gt

&amp;lt action-mappings&amp;gt
        &amp;lt action name="LogicMatchForm" path="/logicmatch" scope="request" type="com.myapp.struts.LogicMatchAction" validate="false"&amp;gt
        &amp;lt forward name="success" path="/LogicMatchTag.jsp"/&amp;gt

            &amp;lt/action&amp;gt
&amp;lt/action-mappings&amp;gt

	&amp;lt/struts-config&amp;gt

</code></pre>
<p>6.Building and running the application</p>
<h4><b>Output</b></h4>
<p><b>Access page:
<pre><code>http://localhost:8080/logicmatch/</code></pre>
<p></b></p>
<p><img src="images/2010/10/struts-logicmatch/struts-logicmatch-1.jpg" width="585" height="204"></p>
<p><b>After evaluation the result is displayed</b></p>
<p><img src="images/2010/10/struts-logicmatch/struts-logicmatch-2.jpg" width="585" height="204"></p>
<h2>Struts Framework Articles</h2>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<li><a href="http://www.javabeat.net/articles/67-struts-20-introduction-and-validations-using-annotatio-1.html">Struts 2.0 Introduction and Validations using Annotations</a></li>
<li><a href="http://www.javabeat.net/articles/24-introduction-to-struts-actions-1.html">Introduction to Struts Actions</a></li>
<li><a href="http://www.javabeat.net/articles/69-whats-new-in-struts-20-struts-20-framework-1.html">What&#8217;s new in Struts 2.0?</a></li>
<li><a href="http://www.javabeat.net/articles/132-internationalization-and-taglibs-in-struts-12-1.html">Internationalization and Taglibs in Struts 1.2</a></li>
<p>	</u></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/10/struts-logic-match-and-notmatch-tag-logicmatch-and-logicnotmatch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts LOGIC Iterate Tag ( &lt;logic:iterate&gt; )</title>
		<link>http://www.javabeat.net/2010/10/struts-logic-iterate-tag-logiciterate/</link>
		<comments>http://www.javabeat.net/2010/10/struts-logic-iterate-tag-logiciterate/#comments</comments>
		<pubDate>Sat, 16 Oct 2010 03:10:35 +0000</pubDate>
		<dc:creator>AbhilashEtikala</dc:creator>
				<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=460</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Struts LOGIC Tag Library Struts LOGIC tag library provides tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. Read Integrating Struts With Spring Syntax to use Struts LOGIC tag library 1 &#38;lt%@ taglib prefix=&#34;logic&#34; uri=&#34;http://struts.apache.org/tags-logic&#34; %&#38;gt -This tag repeats [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>Struts LOGIC Tag Library</h2>
<p>Struts <b>LOGIC tag library</b> provides tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. </p>
<ul>
<li>Read <a href="http://www.javabeat.net/articles/70-integrating-struts-with-spring-1.html">Integrating Struts With Spring</a></li>
</ul>
<h2>Syntax to use Struts LOGIC  tag library</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">	&amp;lt%@ taglib prefix=&quot;logic&quot; uri=&quot;http://struts.apache.org/tags-logic&quot; %&amp;gt</pre></td></tr></table></div>

<h2><logic:iterate></h2>
<p><b><logic:iterate></b>-This tag repeats the nested body content of this tag once for every element of the specified collection, which must be an Iterator or  a Collection or  a Map (whose values are to be iterated over), or an array. The collection to be iterated must be specified in any of the form like a runtime expression spcified as the value of the <i>collection</i> attribute,as Jsp bean spcified by the <i>name</i> attribute or as the property, specified by the <i>property</i>, of the JSP bean specified by the <i>name</i> attribute </p>
<p>If the collection you are iterating over can contain null values, the loop will still be performed but no page scope attribute (named by the id attribute) will be created for that loop iteration.</p>
<h2>Example Code for <logic:iterate > </h2>
<p>1.Create of Modify the <b>index.jsp page</b> which redirects to the action class to set the values.</p>
<p><b>index.jsp</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&amp;lt %@page contentType=&quot;text/html&quot;%&amp;gt
&amp;lt %@page pageEncoding=&quot;UTF-8&quot;%&amp;gt
&amp;lt jsp:forward page=&quot;logiciterate.do&quot;&amp;gt</pre></td></tr></table></div>

<p>2.Create an Jsp page and name it as <b>LogicIterateTag.jsp</b>.It is the output page for user which contains the logic iterate tag to iterate through the collection and display the result as specified.</p>
<p><b>LogicIterateTag.jsp</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&amp;lt%@page contentType=&quot;text/html&quot; pageEncoding=&quot;UTF-8&quot;%&amp;gt
&amp;lt%@taglib prefix=&quot;html&quot; uri=&quot;http://jakarta.apache.org/struts/tags-html&quot; %&amp;gt
&amp;lt%@taglib prefix=&quot;bean&quot; uri=&quot;http://jakarta.apache.org/struts/tags-bean&quot; %&amp;gt
&amp;lt%@taglib prefix=&quot;logic&quot; uri=&quot;http://jakarta.apache.org/struts/tags-logic&quot; %&amp;gt
&nbsp;
&lt;html&amp;gt
    &lt;head&amp;gt
        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&amp;gt
        &lt;title&amp;gt Struts Logic Iterate Tag&amp;lt /title&amp;gt
    &lt;/head&amp;gt
    &lt;body bgcolor=&quot;DDDDDD&quot;&amp;gt
        &lt;h1&amp;gt Struts logic:iterate tag&amp;lt /h1&amp;gt
          &lt;table style=&quot;font-weight:bold&quot;&gt;
            &lt;tr&gt;&lt;td&gt;Employee ID&lt;/td&gt;&lt;td&gt;Employee Name&lt;/td&gt;&lt;/tr&gt;
        &lt;logic:iterate id=&quot;employee&quot; name=&quot;LogicIterateForm&quot; property=&quot;emp&quot;&gt;
            &lt;tr&gt;&lt;td&gt;&lt;bean:write name=&quot;employee&quot; property=&quot;empid&quot;/&gt;&lt;/td&gt;
           &lt;td&gt; &lt;bean:write name=&quot;employee&quot; property=&quot;empname&quot;/&gt;&lt;/td&gt;
&lt;/tr&gt;
        &lt;/logic:iterate&gt;&lt;/table&gt;
    &lt;/body&amp;gt
&lt;/html&amp;gt</pre></td></tr></table></div>

<p>
3.Create a Employee class <b>Employee.java</b> which contains the details of the employee(employee id and employee name).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&nbsp;
package com.myapp.struts;
&nbsp;
public class Employee {
String empid;
String empname;
&nbsp;
    public String getEmpid() {
        return empid;
    }
&nbsp;
    public void setEmpid(String empid) {
        this.empid = empid;
    }
&nbsp;
    public String getEmpname() {
        return empname;
    }
&nbsp;
    public void setEmpname(String empname) {
        this.empname = empname;
    }
&nbsp;
    public Employee(String empid, String empname) {
        this.empid = empid;
        this.empname = empname;
    }
&nbsp;
&nbsp;
&nbsp;
}</pre></td></tr></table></div>

</p>
<p>4.Create a Form bean.Form bean is used to hold the properties of the submitted form which is a sub class of ActionForm.It contains a List of Employee objects  which are set from the action class.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&#038;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<p>.
	</ul>
</p>
<p><b>LogicIterateForm.java</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
&nbsp;
public class LogicIterateForm extends org.apache.struts.action.ActionForm {
&nbsp;
  private List&lt;employee&gt; emp=new ArrayList&lt;employee&gt;();
&nbsp;
    public List&lt;employee&gt; getEmp() {
        return emp;
    }
&nbsp;
    public void setEmp(List&lt;employee&gt; emp) {
        this.emp = emp;
    }
&nbsp;
&nbsp;
    public LogicIterateForm() {
        super();
&nbsp;
    }
&nbsp;
&nbsp;
}</pre></td></tr></table></div>

<p>5.Simple Action class <b>LogicIterateAction.java</b> which is a sub class of <i>Action</i> class used to process the user&#8217;s request.Here we create and set the employee objects to the form bean. </p>
<p><b>LogicIterateAction.java</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
&nbsp;
public class LogicIterateAction extends org.apache.struts.action.Action {
&nbsp;
    private final static String SUCCESS = &quot;success&quot;;
&nbsp;
&nbsp;
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
    LogicIterateForm formBean=(LogicIterateForm)form;
   ArrayList&lt;employee&gt; list=new ArrayList&lt;employee&gt;();
    list.add(new Employee(&quot;11A0&quot;,&quot;Jack&quot;));
    list.add(new Employee(&quot;11A1&quot;,&quot;Sam&quot;));
    list.add(new Employee(&quot;11A2&quot;,&quot;Joe&quot;));
    list.add(new Employee(&quot;11A3&quot;,&quot;John&quot;));
    formBean.setEmp(list);
        return mapping.findForward(SUCCESS);
    }
}</pre></td></tr></table></div>

<p>6.Create or modify struts config file <b>struts-config.xml</b> with action mappings.Struts-config file contains the information about the configuration of the struts framework to the application.It contains the action mappings which helps to select Action,ActionForm and other information for specific user&#8217;s request&#8217;s.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&nbsp;
&amp;lt?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&amp;gt
&nbsp;
&amp;lt!DOCTYPE struts-config PUBLIC
          &quot;-//Apache Software Foundation//DTD Struts Configuration 1.2//EN&quot;
          &quot;http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd&quot;&amp;gt
&nbsp;
&amp;lt struts-config&amp;gt
    &amp;lt form-beans&amp;gt
        &lt;form-bean name=&quot;LogicIterateForm&quot; type=&quot;com.myapp.struts.LogicIterateForm&quot;/&gt;
    &amp;lt/form-beans&amp;gt
&nbsp;
&amp;lt action-mappings&amp;gt
        &lt;action  name=&quot;LogicIterateForm&quot; path=&quot;/logiciterate&quot; scope=&quot;session&quot; type=&quot;com.myapp.struts.LogicIterateAction&quot; validate=&quot;false&quot;&gt;
        &amp;lt forward name=&quot;success&quot; path=&quot;/LogicIterateTag.jsp&quot;/&amp;gt
&nbsp;
            &amp;lt/action&amp;gt
&amp;lt/action-mappings&amp;gt
&nbsp;
	&amp;lt/struts-config&amp;gt</pre></td></tr></table></div>

<p>6.Building and running the application</p>
<h4><b>Output</b></h4>
<p><b>Access page:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">http://localhost:8080/logiciterate/</pre></td></tr></table></div>

<p></b></p>
<p><img src="images/2010/10/struts-logiciterate/struts-logiciterate-1.jpg" width="585" height="204"></p>
<h2>Struts Framework Articles</h2>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&#038;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<li><a href="http://www.javabeat.net/articles/67-struts-20-introduction-and-validations-using-annotatio-1.html">Struts 2.0 Introduction and Validations using Annotations</a></li>
<li><a href="http://www.javabeat.net/articles/24-introduction-to-struts-actions-1.html">Introduction to Struts Actions</a></li>
<li><a href="http://www.javabeat.net/articles/69-whats-new-in-struts-20-struts-20-framework-1.html">What&#8217;s new in Struts 2.0?</a></li>
<li><a href="http://www.javabeat.net/articles/132-internationalization-and-taglibs-in-struts-12-1.html">Internationalization and Taglibs in Struts 1.2</a></li>
<p>	</u></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/10/struts-logic-iterate-tag-logiciterate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts LOGIC present and notPresent Tag ( &lt;logic:present&gt;  and &lt;logic:notPresent&gt;)</title>
		<link>http://www.javabeat.net/2010/10/struts-logic-present-and-notpresent-tag-logicpresent-and-logicnotpresent/</link>
		<comments>http://www.javabeat.net/2010/10/struts-logic-present-and-notpresent-tag-logicpresent-and-logicnotpresent/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 03:09:56 +0000</pubDate>
		<dc:creator>AbhilashEtikala</dc:creator>
				<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=458</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Struts LOGIC Tag Library Struts LOGIC tag library provides tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. Read Integrating Struts With Spring Syntax to use Struts LOGIC tag library 1 &#38;lt%@ taglib prefix=&#34;logic&#34; uri=&#34;http://struts.apache.org/tags-logic&#34; %&#38;&#62; logic:present and logic:notPresent [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>Struts LOGIC Tag Library</h2>
<p>Struts <b>LOGIC tag library</b> provides tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. </p>
<ul>
<li>Read <a href="http://www.javabeat.net/articles/70-integrating-struts-with-spring-1.html">Integrating Struts With Spring</a></li>
</ul>
<h2>Syntax to use Struts LOGIC  tag library</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">	&amp;lt%@ taglib prefix=&quot;logic&quot; uri=&quot;http://struts.apache.org/tags-logic&quot; %&amp;&gt;</pre></td></tr></table></div>

<h2>logic:present  and logic:notPresent</h2>
<p><b>&lt; logic:present &#038;>	</b>-This tag checks in the current request depending upon the attribuite specified if the specified value <b>is</b> present the nested content of this tag is evaluated.  </p>
<p><b>&lt; logic:notPresent&#038;>	</b>- This tag checks in the current request depending upon the attribuite specified if the specified value <b>is not</b> present  the nested content of this tag is evaluated.</p>
<h2>Example Code for &lt; logic:present &#038;> and &lt; logic:notPresent</h2>
<p>1.Create of Modify the <b>index.jsp page</b> which redirects to the action class to set the values.</p>
<p><b>index.jsp</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&amp;lt %@page contentType=&quot;text/html&quot;%&amp;&gt;
&amp;lt %@page pageEncoding=&quot;UTF-8&quot;%&amp;&gt;
&amp;lt jsp:forward page=&quot;logicpresent.do&quot;&amp;&gt;</pre></td></tr></table></div>

<p>2.Create an Jsp page and name it as <b>LogicPresentTag.jsp</b>.It is the output page for user which contains the logic tags to check the specified attribute in this current request and display the result.</p>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&#038;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<p>.
	</ul>
</p>
<p><b>LogicPresentTag.jsp</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&amp;lt%@page contentType=&quot;text/html&quot; pageEncoding=&quot;UTF-8&quot;%&amp;&gt;
&amp;lt%@taglib prefix=&quot;html&quot; uri=&quot;http://jakarta.apache.org/struts/tags-html&quot; %&amp;&gt;
&amp;lt%@taglib prefix=&quot;bean&quot; uri=&quot;http://jakarta.apache.org/struts/tags-bean&quot; %&amp;&gt;
&nbsp;
&nbsp;
&lt;html&amp;&gt;
    &lt;head&amp;&gt;
        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&amp;&gt;
        &lt;title&amp;&gt; Struts Logic Present Tag&amp;lt /title&amp;&gt;
    &lt;/head&amp;&gt;
    &lt;body bgcolor=&quot;DDDDDD&quot;&amp;&gt;
        &lt;h1&amp;&gt; Struts logic:present and logic:notPresent tag&amp;lt /h1&amp;&gt;
        &lt;logic:present property=&quot;name&quot; name=&quot;LogicPresentForm&quot;&amp;&gt;
&lt;h4&amp;&gt; Using &amp;amplt;logic:present &amp;amp&gt;; tag &amp;lt i&amp;&gt; name&amp;lt/i&amp;&gt; is
 &amp;lt bean:write name=&quot;LogicPresentForm&quot; property=&quot;name&quot;/&amp;&gt;
&amp;lt /h4&amp;&gt;
&lt;/logic:present&amp;&gt;
            &lt;logic:notPresent name=&quot;LogicPresentForm&quot; property =&quot;number&quot; &amp;&gt;
&lt;h4&amp;&gt; Using &amp;amplt; logic:notPresent&amp;amp&gt;; tag  &lt;i&gt;number&lt;/i&gt; is not set &lt; /h4&amp;&gt;
&nbsp;
            &lt;/logic:notPresent&amp;&gt;
    &lt;/body&amp;&gt;
&lt;/html&amp;&gt;</pre></td></tr></table></div>

<p>3.Create a Form bean.Form bean is used to hold the properties of the submitted form which is a sub class of ActionForm.It contains only two properties of type int and String to hold the integer number and name which are set from the action class.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p><b>LogicPresentForm.java</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
&nbsp;
public class LogicPresentForm extends org.apache.struts.action.ActionForm {
&nbsp;
    private String name;
&nbsp;
    public String getName() {
        return name;
    }
&nbsp;
    public void setName(String string) {
        name = string;
    }
&nbsp;
&nbsp;
    public LogicPresentForm() {
        super();
&nbsp;
    }
&nbsp;
&nbsp;
}</pre></td></tr></table></div>

<p>4.Simple Action class <b>LogicPresentAction.java</b> which is a sub class of <i>Action</i> class used to process the user&#8217;s request. </p>
<p><b>LogicPresentAction.java</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
&nbsp;
public class LogicPresentAction extends org.apache.struts.action.Action {
&nbsp;
&nbsp;
    private final static String SUCCESS = &quot;success&quot;;
&nbsp;
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        LogicPresentForm formBean=(LogicPresentForm)form;
        formBean.setName(&quot;Java Struts&quot;);
&nbsp;
        return mapping.findForward(SUCCESS);
    }
}</pre></td></tr></table></div>

<p>5.Create or modify struts config file <b>struts-config.xml</b> with action mappings.Struts-config file contains the information about the configuration of the struts framework to the application.It contains the action mappings which helps to select Action,ActionForm and other information for specific user&#8217;s request&#8217;s.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&nbsp;
&amp;lt?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&amp;&gt;
&nbsp;
&amp;lt!DOCTYPE struts-config PUBLIC
          &quot;-//Apache Software Foundation//DTD Struts Configuration 1.2//EN&quot;
          &quot;http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd&quot;&amp;&gt;
&nbsp;
&amp;lt struts-config&amp;&gt;
    &amp;lt form-beans&amp;&gt;
        &amp;ltform-bean name=&quot;LogicPresentForm&quot; type=&quot;com.myapp.struts.LogicPresentForm&quot;/&amp;&gt;
    &amp;lt/form-beans&amp;&gt;
&nbsp;
&amp;lt action-mappings&amp;&gt;
        &amp;lt action name=&quot;LogicPresentForm&quot; path=&quot;/logicpresent&quot; scope=&quot;session&quot; type=&quot;com.myapp.struts.LogicPresentAction&quot; validate=&quot;false&quot;&amp;&gt;
        &amp;lt forward name=&quot;success&quot; path=&quot;/LogicPresentTag.jsp&quot;/&amp;&gt;
&nbsp;
            &amp;lt/action&amp;&gt;
&amp;lt/action-mappings&amp;&gt;
&nbsp;
	&amp;lt/struts-config&amp;&gt;</pre></td></tr></table></div>

<p>6.Building and running the application</p>
<h4><b>Output</b></h4>
<p><b>Access page:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">http://localhost:8080/logicpresent/</pre></td></tr></table></div>

<p></b></p>
<p><img src="images/2010/10/struts-logicpresent/struts-logicpresent-1.jpg" width="585" height="204"></p>
<h2>Struts Framework Articles</h2>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&#038;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<li><a href="http://www.javabeat.net/articles/67-struts-20-introduction-and-validations-using-annotatio-1.html">Struts 2.0 Introduction and Validations using Annotations</a></li>
<li><a href="http://www.javabeat.net/articles/24-introduction-to-struts-actions-1.html">Introduction to Struts Actions</a></li>
<li><a href="http://www.javabeat.net/articles/69-whats-new-in-struts-20-struts-20-framework-1.html">What&#8217;s new in Struts 2.0?</a></li>
<li><a href="http://www.javabeat.net/articles/132-internationalization-and-taglibs-in-struts-12-1.html">Internationalization and Taglibs in Struts 1.2</a></li>
<p>	</u></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/10/struts-logic-present-and-notpresent-tag-logicpresent-and-logicnotpresent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts LOGIC lessEqual and lessThan Tag ( &lt; logic:lessEqual &gt;  and &lt; logic:lessThan &gt;)</title>
		<link>http://www.javabeat.net/2010/10/struts-logic-lessequal-and-lessthan-tag-logiclessequal-and-logiclessthan/</link>
		<comments>http://www.javabeat.net/2010/10/struts-logic-lessequal-and-lessthan-tag-logiclessequal-and-logiclessthan/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 03:09:19 +0000</pubDate>
		<dc:creator>AbhilashEtikala</dc:creator>
				<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=456</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Struts LOGIC lessEqual and lessThan Tag ( &#60; logic:lessEqual &#62; and &#60; logic:lessThan &#62;) Struts LOGIC Tag Library Struts LOGIC tag library provides tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. Read Integrating Struts With Spring Syntax to [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h1>Struts LOGIC lessEqual and lessThan Tag ( &lt; logic:lessEqual &gt;  and &lt; logic:lessThan &gt;) </h1>
<h2>Struts LOGIC Tag Library</h2>
<p>Struts <b>LOGIC tag library</b> provides tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. </p>
<ul>
<li>Read <a href="http://www.javabeat.net/articles/70-integrating-struts-with-spring-1.html">Integrating Struts With Spring</a></li>
</ul>
<h2>Syntax to use Struts LOGIC  tag library</h2>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<p>.
	</ul>
</p>
<pre>
	<code>&amp;lt%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %&amp;gt</code>
</pre>
<h2>&amp;lt logic:lessEqual &amp;gt and &amp;lt logic:lessThan&amp;gt</h2>
<p><b>&amp;lt logic:lessEqual &amp;gt	</b>-This tag compares between the selector attributes and the specified constant variable.If the variable is <b>less than or equal</b> the content the nested content of this tag is evaluated.  </p>
<p><b>&amp;lt logic:lessThan &amp;gt	</b>- This tag compares between the selector attributes and the specified constant variable.If the variable is <b>less than  </b> the content the nested content of this tag is evaluated.</p>
<h2>Example Code for &amp;lt logic:lessEqual &amp;gt and &amp;lt logic:lessThan&amp;gt</h2>
<p>1.Create of Modify the <b>index.jsp page</b> whic is the welcome page for the users.It displays a Textbox nested inside the form where the number is to be entered.</p>
<p><b>index.jsp</b></p>
<pre><code>
&amp;lt %@page contentType="text/html" pageEncoding="UTF-8"%&amp;gt
&amp;lt %@taglib  uri="http://struts.apache.org/tags-html" prefix="html" %&amp;gt
&amp;lt !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd"&amp;gt

&amp;lt html&amp;gt
    &amp;lt head&amp;gt
        &amp;lt meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&amp;gt
        &amp;lt title&amp;gt Struts Logic Less Example&amp;lt /title&amp;gt
    &amp;lt /head&amp;gt
    &amp;lt body bgcolor="DDDDDD"&amp;gt
        &amp;lt h1&amp;gt Struts logic:lessEqual and logic:lessThan tag example&amp;lt /h1&amp;gt
        &amp;lt html:form action="/logicless"&amp;gt
        &amp;lt h3&amp;gt Enter any number:&amp;lt /h3&amp;gt
        &amp;lt html:text property="number"/&amp;gt
        &amp;lt html:submit/&amp;gt&amp;lt html:cancel/&amp;gt
        &amp;lt /html:form&amp;gt
    &amp;lt /body&amp;gt
&amp;lt /html&amp;gt
</code></pre>
<p>2.Create an Jsp page and name it as <b>LogicTagLessExample.jsp</b>.It is the output page for user which contains the logic tags to evaluate the number and display whether lessthan or equal to a given specified value.</p>
<p><b>LogicTagLessExample.jsp</b></p>
<pre><code>
&amp;lt%@page contentType="text/html" pageEncoding="UTF-8"%&amp;gt
&amp;lt%@taglib prefix="html" uri="http://jakarta.apache.org/struts/tags-html" %&amp;gt
&amp;lt%@taglib prefix="bean" uri="http://jakarta.apache.org/struts/tags-bean" %&amp;gt


&amp;lt html&amp;gt
    &amp;lt head&amp;gt
        &amp;lt meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&amp;gt
        &amp;lt title&amp;gt Struts Logic Less Equal and Than&amp;lt /title&amp;gt
    &amp;lt /head&amp;gt
    &amp;lt body bgcolor="DDDDDD"&amp;gt
        &amp;lt h1&amp;gt Logic LessEqual and LessThan Example&amp;lt /h1&amp;gt
        &amp;lt logic:lessEqual name="LogicLessForm" property ="number" value="100"&amp;gt
&amp;lt h4&amp;gt Using &lt; logic:lessEqual&gt; tag &amp;lt /h4&amp;gt
&amp;lt h3&amp;gt Given Number is LessEqual to 100&amp;lt /h3&amp;gt
            &amp;lt /logic:lessEqual&amp;gt
            &amp;lt logic:lessThan name="LogicLessForm" property ="number" value="1000"&amp;gt
&amp;lt h4&amp;gt Using &lt; logic:lessThan&gt; tag &amp;lt /h4&amp;gt
&amp;lt h3&amp;gt Given Number is LessThan 1000&amp;lt /h3&amp;gt
            &amp;lt /logic:lessThan&amp;gt
    &amp;lt /body&amp;gt
&amp;lt /html&amp;gt

</code></pre>
<p>3.Create a Form bean.Form bean is used to hold the properties of the submitted form which is a sub class of ActionForm.It contains only one property of type int to hold the integer number to compare.</p>
<p><b>LogicLessForm.java</b></p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<pre><code>
package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LogicLessForm extends org.apache.struts.action.ActionForm {

private int number;

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public LogicLessForm() {
        super();

    }


}

</code></pre>
<p>4.Simple Action class <b>LogicLessAction.java</b> which is a sub class of <i>Action</i> class used to process the user&#8217;s request. </p>
<p><b>LogicLessAction.java</b></p>
<pre><code>
package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

public class LogicLessAction extends org.apache.struts.action.Action {


    private final static String SUCCESS = "success";

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        return mapping.findForward(SUCCESS);
    }
}


</code></pre>
<p>5.Create or modify struts config file <b>struts-config.xml</b> with action mappings.Struts-config file contains the information about the configuration of the struts framework to the application.It contains the action mappings which helps to select Action,ActionForm and other information for specific user&#8217;s request&#8217;s.</p>
<pre><code>

&amp;lt?xml version="1.0" encoding="UTF-8" ?&amp;gt

&amp;lt!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"&amp;gt

&amp;lt struts-config&amp;gt
    &amp;lt form-beans&amp;gt
        &amp;lt form-bean name="LogicLessForm" type="com.myapp.struts.LogicLessForm"/&amp;gt
    &amp;lt/form-beans&amp;gt

&amp;lt action-mappings&amp;gt
        &amp;lt action name="LogicLessForm" path="/logicless" scope="request" type="com.myapp.struts.LogicLessAction" validate="false"&amp;gt
        &amp;lt forward name="success" path="/LogicTagLessExample.jsp"/&amp;gt

            &amp;lt/action&amp;gt
&amp;lt/action-mappings&amp;gt

	&amp;lt/struts-config&amp;gt

</code></pre>
<p>6.Building and running the application</p>
<h4><b>Output</b></h4>
<p><b>Access page:
<pre><code>http://localhost:8080/logicless/</code></pre>
<p></b></p>
<p><img src="images/2010/10/struts-logicless/struts-logicless-1.jpg" width="585" height="204"></p>
<p><b>After evaluation the result is displayed</b></p>
<p><img src="images/2010/10/struts-logicless/struts-logicless-2.jpg" width="585" height="204"></p>
<h2>Struts Framework Articles</h2>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<li><a href="http://www.javabeat.net/articles/67-struts-20-introduction-and-validations-using-annotatio-1.html">Struts 2.0 Introduction and Validations using Annotations</a></li>
<li><a href="http://www.javabeat.net/articles/24-introduction-to-struts-actions-1.html">Introduction to Struts Actions</a></li>
<li><a href="http://www.javabeat.net/articles/69-whats-new-in-struts-20-struts-20-framework-1.html">What&#8217;s new in Struts 2.0?</a></li>
<li><a href="http://www.javabeat.net/articles/132-internationalization-and-taglibs-in-struts-12-1.html">Internationalization and Taglibs in Struts 1.2</a></li>
<p>	</u></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/10/struts-logic-lessequal-and-lessthan-tag-logiclessequal-and-logiclessthan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts LOGIC greaterEqual and greaterThan Tag ( &lt;logic:greaterEqual&gt;  and &lt;logic:greaterThan&gt;)</title>
		<link>http://www.javabeat.net/2010/10/struts-logic-greaterequal-and-greaterthan-tag-logicgreaterequal-and-logicgreaterthan/</link>
		<comments>http://www.javabeat.net/2010/10/struts-logic-greaterequal-and-greaterthan-tag-logicgreaterequal-and-logicgreaterthan/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 03:08:33 +0000</pubDate>
		<dc:creator>AbhilashEtikala</dc:creator>
				<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=454</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Struts LOGIC greaterEqual and greaterThan Tag ( &#60;logic:greaterEqual&#62; and &#60;logic:greaterThan&#62;) Struts LOGIC Tag Library Struts LOGIC tag library provides tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. Read Integrating Struts With Spring Syntax to use Struts LOGIC tag [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h1>Struts LOGIC greaterEqual and greaterThan Tag ( &lt;logic:greaterEqual&gt;  and &lt;logic:greaterThan&gt;) </h1>
<h2>Struts LOGIC Tag Library</h2>
<p>Struts <b>LOGIC tag library</b> provides tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. </p>
<ul>
<li>Read <a href="http://www.javabeat.net/articles/70-integrating-struts-with-spring-1.html">Integrating Struts With Spring</a></li>
</ul>
<h2>Syntax to use Struts LOGIC  tag library</h2>
<pre>
	<code>&amp;lt%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %&amp;gt</code>
</pre>
<h2>&amp;lt logic:greaterEqual &amp;gt and &amp;lt logic:greaterThan&amp;gt</h2>
<p><b>&amp;lt logic:greaterEqual &amp;gt	</b>-This tag compares between the selector attributes and the specified constant variable.If the variable is <b>greater than or equal</b> the content the nested content of this tag is evaluated.  </p>
<p><b>&amp;lt logic:lessThan &amp;gt	</b>- This tag compares between the selector attributes and the specified constant variable.If the variable is <b>greater than  </b> the content the nested content of this tag is evaluated.</p>
<h2>Example Code for &amp;lt logic:greaterEqual &amp;gt and &amp;lt logic:greaterThan&amp;gt</h2>
<p>1.Create of Modify the <b>index.jsp page</b> whic is the welcome page for the users.It displays a Textbox nested inside the form where the number is to be entered.</p>
<p><b>index.jsp</b></p>
<pre><code>
&amp;lt %@page contentType="text/html" pageEncoding="UTF-8"%&amp;gt
&amp;lt %@taglib  uri="http://struts.apache.org/tags-html" prefix="html" %&amp;gt
&amp;lt !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd"&amp;gt

&lt;html&amp;gt
    &lt;head&amp;gt
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&amp;gt
        &lt;title&amp;gt Struts Logic Greater Than and Equal Tag&lt;/title&amp;gt
    &lt;/head&amp;gt
    &amp;lt body bgcolor="DDDDDD"&amp;gt
        &lt;h1&amp;gt Struts logic:greaterEqual and logic:greaterThan tags &lt;/h1&amp;gt
        &lt;html:form action="/logicgreater"&amp;gt
        &lt;h3&amp;gt Enter any number:&lt;/h3&amp;gt
        &lt;html:text property="number"/&amp;gt
        &lt;html:submit/&amp;gt&amp;lt html:cancel/&amp;gt
        &lt;/html:form&amp;gt
    &lt;/body&amp;gt
&lt;/html&amp;gt
</code></pre>
<p>2.Create an Jsp page and name it as <b>LogicGreaterTag.jsp</b>.It is the output page for user which contains the logic tags to evaluate the number and display whether greater than or equal to a given specified value.</p>
<p><b>LogicGreaterTag.jsp</b></p>
<pre><code>
&amp;lt%@page contentType="text/html" pageEncoding="UTF-8"%&amp;gt
&amp;lt%@taglib prefix="html" uri="http://jakarta.apache.org/struts/tags-html" %&amp;gt
&amp;lt%@taglib prefix="bean" uri="http://jakarta.apache.org/struts/tags-bean" %&amp;gt


&lt;html&amp;gt
    &lt;head&amp;gt
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&amp;gt
        &lt;title&amp;gt Struts Logic Greater Tag Example&amp;lt /title&amp;gt
    &lt;/head&amp;gt
    &lt;body bgcolor="DDDDDD"&amp;gt
        &lt;h1&amp;gt Struts logic:greaterThan and logic:greaterEqual tag example&amp;lt /h1&amp;gt
        &lt;logic:greaterThan name="LogicGreaterForm" property ="number" value="10"&amp;gt
&lt;h4&amp;gt Using &lt;logic:greaterThan&gt; tag &amp;lt /h4&amp;gt
&lt;h3&amp;gt Given Number is Greater Than 10&amp;lt /h3&amp;gt
            &lt;/logic:greaterThan&amp;gt
            &lt;logic:greaterEqual name="LogicGreaterForm" property ="number" value="100"&amp;gt
&lt;h4&amp;gt Using &lt; logic:greaterEqual&gt; tag &lt;/h4&amp;gt
&lt;h3&amp;gt Given Number is Greater Equal to 100&lt;/h3&amp;gt
            &lt;/logic:greaterEqual&amp;gt
    &lt;/body&amp;gt
&lt;/html&amp;gt

</code></pre>
<p>3.Create a Form bean.Form bean is used to hold the properties of the submitted form which is a sub class of ActionForm.It contains only one property of type int to hold the integer number to compare.</p>
<p><b>LogicGreaterForm.java</b></p>
<pre><code>
package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LogicLessForm extends org.apache.struts.action.ActionForm {

private int number;

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public LogicLessForm() {
        super();

    }


}

</code></pre>
<p>4.Simple Action class <b>LogicGreaterAction.java</b> which is a sub class of <i>Action</i> class used to process the user&#8217;s request. </p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<p>.
	</ul>
</p>
<p><b>LogicGreaterAction.java</b></p>
<pre><code>
package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

public class LogicLessAction extends org.apache.struts.action.Action {


    private final static String SUCCESS = "success";

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        return mapping.findForward(SUCCESS);
    }
}


</code></pre>
<p>5.Create or modify struts config file <b>struts-config.xml</b> with action mappings.Struts-config file contains the information about the configuration of the struts framework to the application.It contains the action mappings which helps to select Action,ActionForm and other information for specific user&#8217;s request&#8217;s.</p>
<pre><code>

&amp;lt?xml version="1.0" encoding="UTF-8" ?&amp;gt

&amp;lt!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"&amp;gt

&amp;lt struts-config&amp;gt
    &amp;lt form-beans&amp;gt
        &amp;lt form-bean name="LogicGreaterForm" type="com.myapp.struts.LogicGreaterForm"/&amp;gt
    &amp;lt/form-beans&amp;gt

&amp;lt action-mappings&amp;gt
        &amp;lt action name="LogicGreaterForm" path="/logicgreater" scope="request" type="com.myapp.struts.LogicGreaterAction" validate="false"&amp;gt
        &amp;lt forward name="success" path="/LogicGreaterTag.jsp"/&amp;gt

            &amp;lt/action&amp;gt
&amp;lt/action-mappings&amp;gt

	&amp;lt/struts-config&amp;gt

</code></pre>
<p>6.Building and running the application</p>
<h4><b>Output</b></h4>
<p><b>Access page:
<pre><code>http://localhost:8080/logicgreater/</code></pre>
<p></b></p>
<p><img src="images/2010/10/struts-logicgreater/struts-logicgreater-1.jpg" width="585" height="204"></p>
<p><b>After evaluation the result is displayed</b></p>
<p><img src="images/2010/10/struts-logicgreater/struts-logicgreater-2.jpg" width="585" height="204"></p>
<h2>Struts Framework Articles</h2>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<li><a href="http://www.javabeat.net/articles/67-struts-20-introduction-and-validations-using-annotatio-1.html">Struts 2.0 Introduction and Validations using Annotations</a></li>
<li><a href="http://www.javabeat.net/articles/24-introduction-to-struts-actions-1.html">Introduction to Struts Actions</a></li>
<li><a href="http://www.javabeat.net/articles/69-whats-new-in-struts-20-struts-20-framework-1.html">What&#8217;s new in Struts 2.0?</a></li>
<li><a href="http://www.javabeat.net/articles/132-internationalization-and-taglibs-in-struts-12-1.html">Internationalization and Taglibs in Struts 1.2</a></li>
<p>	</u></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/10/struts-logic-greaterequal-and-greaterthan-tag-logicgreaterequal-and-logicgreaterthan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts BEAN Resource Tag ( &lt; bean:resource &gt;)</title>
		<link>http://www.javabeat.net/2010/10/struts-bean-resource-tag-beanresource/</link>
		<comments>http://www.javabeat.net/2010/10/struts-bean-resource-tag-beanresource/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 03:07:39 +0000</pubDate>
		<dc:creator>AbhilashEtikala</dc:creator>
				<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=452</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Struts BEAN Resource Tag ( &#60; bean:resource &#62;) Struts BEAN Tag Library Struts BEAN tag library provides tags which are usefull in accessing beans and their properties as well as defining new beans (based on these accesses) that are accessible to the remainder of the page via scripting variables and page scope attributes. Convenient mechanisms [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h1>Struts BEAN Resource Tag ( &lt; bean:resource &gt;) </h1>
<h2>Struts BEAN Tag Library</h2>
<p><b><a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts</a> BEAN tag library</b> provides tags which are usefull in accessing beans and their properties as well as defining new beans (based on these accesses) that are accessible to the remainder of the page via scripting variables and page scope attributes. Convenient mechanisms to create new beans based on the value of request cookies, headers, and parameters are also provided. </p>
<ul>
<li>Read <a href="http://www.javabeat.net/articles/70-integrating-struts-with-spring-1.html">Integrating Struts With Spring</a></li>
</ul>
<h2>Syntax to use Struts BEAN  tag library</h2>
<pre>
	<code>&amp;lt%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %&amp;gt</code>
</pre>
<h2>&amp;lt bean:resource &amp;gt</h2>
<p><b>&amp;lt bean:resource &amp;gt	</b>- It is used to load a web application resource and make it available as a bean. Retrieves the value of the specified web application resource and make it available as Input Stream or String depending on the input attribute value. </p>
<h2>Example Code for &amp;lt bean:resource&amp;gt</h2>
<p>In this example we do not need the ActionForm bean.</p>
<p>In this example we do not need the Action class.</p>
<p>No need to configure struts-config.xml file</p>
<p>1.Create a simple jsp page <b>BeanResourceTag.jsp</b>.In this page we specify the particular web application resource by <i>name</i> attribute of this tag and id to make available it as a bean.In this example we load a Sample jsp page and display its content.
<pre><code>
&amp;lt%@page contentType="text/html" pageEncoding="UTF-8"%&amp;gt
&amp;lt%@taglib prefix="html" uri="http://jakarta.apache.org/struts/tags-html" %&amp;gt
&amp;lt%@taglib prefix="bean" uri="http://jakarta.apache.org/struts/tags-bean" %&amp;gt


&amp;lt html&amp;gt
    &amp;lt head&amp;gt

        &amp;lt title&amp;gt Struts Bean Resource Tag &amp;lt/title&amp;gt
    &amp;lt head&amp;gt
    &amp;lt body bgcolor="#DDDDDD"&amp;gt
        &amp;lt h1 &amp;gt bean:resource tag example  &amp;lt/h1&amp;gt



		   &amp;lt bean:resource id="Samplejsp" name="/Sample.jsp"/&amp;gt

            &amp;lt h3&amp;gt Content of SampleJsp Page which is loaded as web application resource&amp;lt/h3&amp;gt
			&amp;lt bean:write name="Samplejsp" /&amp;gt &amp;lt br&amp;gt

		  &amp;lt/body&amp;gt
&amp;lt/html&amp;gt

</code></pre>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<p>.
	</ul>
</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p>2.Create any Sample jsp page which will be displayed here we used <b>Sample.jsp</b> page to be loaded.</p>
<p>3.Building and running the application</p>
<h4><b>Output</b></h4>
<p><b>Access page:
<pre><code>http://localhost:8084/beanresource/BeanResourceTag.jsp</code></pre>
<p></b></p>
<p><img src="images/2010/10/struts-beanresource/struts-beanresource-1.jpg" width="585" height="204"></p>
<h2>Struts Framework Articles</h2>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<li><a href="http://www.javabeat.net/articles/67-struts-20-introduction-and-validations-using-annotatio-1.html">Struts 2.0 Introduction and Validations using Annotations</a></li>
<li><a href="http://www.javabeat.net/articles/24-introduction-to-struts-actions-1.html">Introduction to Struts Actions</a></li>
<li><a href="http://www.javabeat.net/articles/69-whats-new-in-struts-20-struts-20-framework-1.html">What&#8217;s new in Struts 2.0?</a></li>
<li><a href="http://www.javabeat.net/articles/132-internationalization-and-taglibs-in-struts-12-1.html">Internationalization and Taglibs in Struts 1.2</a></li>
<p>	</u></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/10/struts-bean-resource-tag-beanresource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts BEAN Size and Header Tag ( &lt; bean:size &gt;  and &lt; bean:header &gt;)</title>
		<link>http://www.javabeat.net/2010/10/struts-bean-size-and-header-tag-beansize-and-beanheader/</link>
		<comments>http://www.javabeat.net/2010/10/struts-bean-size-and-header-tag-beansize-and-beanheader/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 03:02:56 +0000</pubDate>
		<dc:creator>AbhilashEtikala</dc:creator>
				<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=450</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Struts BEAN Size and Header Tag ( &#60; bean:size &#62; and &#60; bean:header &#62;) Struts BEAN Tag Library p&#62;Struts BEAN tag library provides tags which are usefull in accessing beans and their properties as well as defining new beans (based on these accesses) that are accessible to the remainder of the page via scripting variables [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h1>Struts BEAN Size and Header Tag ( &lt; bean:size &gt;  and &lt; bean:header &gt;) </h1>
<h2>Struts BEAN Tag Library</h2>
<p>p&gt;<b><a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts</a> BEAN tag library</b> provides tags which are usefull in accessing beans and their properties as well as defining new beans (based on these accesses) that are accessible to the remainder of the page via scripting variables and page scope attributes. Convenient mechanisms to create new beans based on the value of request cookies, headers, and parameters are also provided. </p>
<p>
<ul>
<li>Read <a href="http://www.javabeat.net/articles/70-integrating-struts-with-spring-1.html">Integrating Struts With Spring</a></li>
</ul>
<h2>Syntax to use Struts BEAN  tag library</h2>
<pre>
	<code>&amp;lt%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %&amp;gt</code>
</pre>
<h2>&amp;lt bean:size &amp;gt and &amp;lt bean:header&amp;gt</h2>
<p><b>&amp;lt bean:size &amp;gt	</b>-This tag defines a new bean containing the number of elements in the specified Collection or Map.Collection size can be counted in any way as a runtime expression specified as the value of the collection attribute or by JSP bean specified by the <i>name </i>attribute or as specified by property of the bean by the <i>property </i> attribute with respect to given name attribute.  </p>
<p><b>&amp;lt bean:header &amp;gt	</b>- It is used to define a scripting variable based on the values of the specified request header. It retrieves the specified request header and define the result as the page scope attribute of type <i>String or String[]</i></p>
<h2>Example Code for &amp;lt bean:size &amp;gt and &amp;lt bean:header&amp;gt</h2>
<p>1.Create an Jsp page and name it as <b>BeanSizeTag.jsp</b>.It displays the size of the collection specified in the name and property attributes of the <i>&amp;lt bean:size &amp;gt </i>tag. Displays the header information of the page using <i>&amp;lt bean:header&amp;gt </i>tag in this example we define two request header values (user-agent,host) and make available as the page context attribute and display.</p>
<p><b>BeanSizeTag.jsp</b></p>
<pre><code>
&amp;lt%@page contentType="text/html" pageEncoding="UTF-8"%&amp;gt
&amp;lt%@taglib prefix="html" uri="http://jakarta.apache.org/struts/tags-html" %&amp;gt
&amp;lt%@taglib prefix="bean" uri="http://jakarta.apache.org/struts/tags-bean" %&amp;gt


&amp;lt html&amp;gt
    &amp;lt head&amp;gt

        &amp;lt title&amp;gt Bean Size and Header Tag&amp;lt/title&amp;gt
    &amp;lt head&amp;gt
    &amp;lt body bgcolor="#DDDDDD"&amp;gt
        &amp;lt h1 &amp;gt bean:size and bean:header tag example &amp;lt/h1&amp;gt



		   &amp;lt bean:size id="beansize" name="BeanSizeForm" property="list"/&amp;gt

            &amp;lt h3&amp;gt Size of the Collection in the Form Bean is:&amp;lt/h3&amp;gt
			&amp;lt bean:write name="beansize" /&amp;gt &amp;lt br&amp;gt

		  &amp;lt h2&amp;gt Some of Header Object's values&amp;lt/h2&amp;gt
		   &amp;lt h3&amp;gt user agent:&amp;lt/h3&amp;gt
		    &amp;lt bean:header id="header_agent" name="user-agent"/&amp;gt
			 &amp;lt bean:write name="header_agent"/&amp;gt
			  &amp;lt h3&amp;gt localhost:&amp;lt/h3&amp;gt
		    &amp;lt bean:header id="header_host" name="host"/&amp;gt
			 &amp;lt bean:write name="header_host"/&amp;gt
		  &amp;lt/body&amp;gt
&amp;lt/html&amp;gt

</code></pre>
<p>2.Create a Form bean.Form bean is used to hold the properties of the submitted form which is a sub class of ActionForm.It contains a <i>list</i> of type <i>ArrayList</i> which contains the elements of Integer objects.In this example list is initialized with numbers from 1 to 10 of Integer objects.</p>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<p>.
	</ul>
</p>
<p><b>BeanSizeForm.java</b></p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<pre><code>
package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class BeanSizeForm extends org.apache.struts.action.ActionForm {

private ArrayList&amp;lt Integer&amp;gt list=new ArrayList&amp;lt Integer&amp;gt();

    public ArrayList&amp;lt Integer&amp;gt getList() {
        return list;
    }

    public void setList() {
        for(int i=0;i&amp;lt 10;i++)
        this.list.add(i) ;
    }

    public BeanSizeForm() {
        super();

    }

  }

</code></pre>
<p>3.Simple Action class <b>BeanSizeAction.java</b> which is a sub class of <i>Action</i> class used to process the user&#8217;s request.In this class  we set the list in the ActionForm bean. </p>
<p><b>BeanSizeAction.java</b></p>
<pre><code>
package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

public class BeanSizeAction extends org.apache.struts.action.Action {


    private final static String SUCCESS = "success";

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
       BeanSizeForm formBean=(BeanSizeForm)form;
       formBean.setList();
        return mapping.findForward(SUCCESS);
    }
}


</code></pre>
<p>4.Create or modify struts config file <b>struts-config.xml</b> with action mappings.Struts-config file contains the information about the configuration of the struts framework to the application.It contains the action mappings which helps to select Action,ActionForm and other information for specific user&#8217;s request&#8217;s.</p>
<pre><code>

&amp;lt?xml version="1.0" encoding="UTF-8" ?&amp;gt

&amp;lt!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"&amp;gt

&amp;lt struts-config&amp;gt
    &amp;lt form-beans&amp;gt
        &amp;lt form-bean name="BeanSizeForm" type="com.myapp.struts.BeanSizeForm"/&amp;gt
    &amp;lt/form-beans&amp;gt

&amp;lt action-mappings&amp;gt
        &amp;lt action name="BeanSizeForm" path="/size" scope="request" type="com.myapp.struts.BeanSizeAction" validate="false"&amp;gt
        &amp;lt forward name="success" path="/BeanSizeTag.jsp"/&amp;gt

            &amp;lt/action&amp;gt
&amp;lt/action-mappings&amp;gt

	&amp;lt/struts-config&amp;gt

</code></pre>
<p>5.Modify <b>index.jsp</b> which conatins the jsp forward to the action class .</p>
<pre><code>

&amp;lt%@page contentType="text/html"%&amp;gt
&amp;lt%@page pageEncoding="UTF-8"%&amp;gt

&amp;lt jsp:forward page="size.do"/&amp;gt

</code></pre>
<p>6.Building and running the application</p>
<h4><b>Output</b></h4>
<p><b>Access page:
<pre><code>http://localhost:8080/beansize/</code></pre>
<p></b></p>
<p><img src="images/2010/10/struts-beansizeandheader/struts-beansizeandheader-1.jpg" width="585" height="204"></p>
<h2>Struts Framework Articles</h2>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&amp;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<li><a href="http://www.javabeat.net/articles/67-struts-20-introduction-and-validations-using-annotatio-1.html">Struts 2.0 Introduction and Validations using Annotations</a></li>
<li><a href="http://www.javabeat.net/articles/24-introduction-to-struts-actions-1.html">Introduction to Struts Actions</a></li>
<li><a href="http://www.javabeat.net/articles/69-whats-new-in-struts-20-struts-20-framework-1.html">What&#8217;s new in Struts 2.0?</a></li>
<li><a href="http://www.javabeat.net/articles/132-internationalization-and-taglibs-in-struts-12-1.html">Internationalization and Taglibs in Struts 1.2</a></li>
<p>	</u></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/10/struts-bean-size-and-header-tag-beansize-and-beanheader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts BEAN Paramter Tag ( &lt; bean:parameter &gt;)</title>
		<link>http://www.javabeat.net/2010/10/struts-bean-paramter-tag-beanparameter/</link>
		<comments>http://www.javabeat.net/2010/10/struts-bean-paramter-tag-beanparameter/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 03:01:26 +0000</pubDate>
		<dc:creator>AbhilashEtikala</dc:creator>
				<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=446</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Struts BEAN Tag Library Struts BEAN tag library provides tags which are usefull in accessing beans and their properties as well as defining new beans (based on these accesses) that are accessible to the remainder of the page via scripting variables and page scope attributes. Convenient mechanisms to create new beans based on the value [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>Struts BEAN Tag Library</h2>
<p><b><a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&#038;node=13" target="_blank">Struts</a> BEAN tag library</b> provides tags which are usefull in accessing beans and their properties as well as defining new beans (based on these accesses) that are accessible to the remainder of the page via scripting variables and page scope attributes. Convenient mechanisms to create new beans based on the value of request cookies, headers, and parameters are also provided. </p>
<ul>
<li>Read <a href="http://www.javabeat.net/articles/70-integrating-struts-with-spring-1.html">Integrating Struts With Spring</a></li>
</ul>
<h2>Syntax to use Struts BEAN  tag library</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">	&lt;%@ taglib prefix=&quot;bean&quot; uri=&quot;http://struts.apache.org/tags-bean&quot; %&gt;</pre></td></tr></table></div>

<h2>< bean:parameter ></h2>
<p><b>< bean:parameter >	</b>- It is used to retrieve the value of the specified request parameter and define the result as a page scope attribute of type String (if multiple is not specified).</p>
<h2>Example Code for  bean:parameter</h2>
<p>In this example we do not need the ActionForm bean.</p>
<p>In this example we do not need the Action class.</p>
<p>No need to configure struts-config.xml file</p>
<p>1.Create a simple jsp page <b>BeanParamTag.jsp</b> which illustrates the  bean:parameter tag by retrieving the request parameter value and displaying as a string to the current page.

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;%@page contentType=&quot;text/html&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%@taglib prefix=&quot;html&quot; uri=&quot;http://jakarta.apache.org/struts/tags-html&quot; %&gt;
&lt;%@taglib prefix=&quot;bean&quot; uri=&quot;http://jakarta.apache.org/struts/tags-bean&quot; %&gt;
&nbsp;
&nbsp;
&lt; html&gt;
    &lt; head&gt;
&nbsp;
        &lt; title&gt; Struts Bean Param Tag &lt;/title&gt;
    &lt; head&gt;
    &lt; body bgcolor=&quot;#DDDDDD&quot;&gt;
        &lt; h1 &gt; bean:parameter tag example  &lt;/h1&gt;
		   &lt; bean:parameter name=&quot;parameter1&quot; id=&quot;param1&quot;/&gt;
		   &lt; bean:parameter name=&quot;parameter2&quot; id=&quot;param2&quot; value=&quot;Java Struts&quot;/&gt;
            &lt; h3&gt; Parameter 1:&lt;/h3&gt; &lt; %=param1%&gt; &lt; br&gt;
            &lt; h3&gt; Parameter 2:&lt;/h3&gt; &lt; %=param2% /&gt;
		  &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>2.Modify <i>index.jsp</i> page which redirects to <i>BeanParamTag.jsp</i> page which retreives the parameter values and displays.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&#038;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<p>.
	</ul>
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;%@page contentType=&quot;text/html&quot;%&gt;
&lt;%@page pageEncoding=&quot;UTF-8&quot;%&gt;
&nbsp;
&lt; jsp:forward page=&quot;BeanParamTag.jsp?parameter1=parameter_value&quot;/&gt;</pre></td></tr></table></div>

<p>3.Building and running the application</p>
<h4><b>Output</b></h4>
<p><b>Access page:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">http://localhost:8084/beanparam/index.jsp</pre></td></tr></table></div>

<p></b></p>
<p><img src="images/2010/10/struts-beanparameter/struts-beanparameter-1.jpg" width="585" height="204"></p>
<h2>Struts Framework Articles</h2>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&#038;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<li><a href="http://www.javabeat.net/articles/67-struts-20-introduction-and-validations-using-annotatio-1.html">Struts 2.0 Introduction and Validations using Annotations</a></li>
<li><a href="http://www.javabeat.net/articles/24-introduction-to-struts-actions-1.html">Introduction to Struts Actions</a></li>
<li><a href="http://www.javabeat.net/articles/69-whats-new-in-struts-20-struts-20-framework-1.html">What&#8217;s new in Struts 2.0?</a></li>
<li><a href="http://www.javabeat.net/articles/132-internationalization-and-taglibs-in-struts-12-1.html">Internationalization and Taglibs in Struts 1.2</a></li>
<p>	</u></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/10/struts-bean-paramter-tag-beanparameter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struts BEAN Include Tag ( &lt; bean:include &gt;)</title>
		<link>http://www.javabeat.net/2010/10/struts-bean-include-tag-beaninclude/</link>
		<comments>http://www.javabeat.net/2010/10/struts-bean-include-tag-beaninclude/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 03:00:29 +0000</pubDate>
		<dc:creator>AbhilashEtikala</dc:creator>
				<category><![CDATA[Struts]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=444</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Struts BEAN Tag Library Struts BEAN tag library provides tags which are usefull in accessing beans and their properties as well as defining new beans (based on these accesses) that are accessible to the remainder of the page via scripting variables and page scope attributes. Convenient mechanisms to create new beans based on the value [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>Struts BEAN Tag Library</h2>
<p><b><a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&#038;node=13" target="_blank">Struts</a> BEAN tag library</b> provides tags which are usefull in accessing beans and their properties as well as defining new beans (based on these accesses) that are accessible to the remainder of the page via scripting variables and page scope attributes. Convenient mechanisms to create new beans based on the value of request cookies, headers, and parameters are also provided. </p>
<ul>
<li>Read <a href="http://www.javabeat.net/articles/70-integrating-struts-with-spring-1.html">Integrating Struts With Spring</a></li>
</ul>
<h2>Syntax to use Struts BEAN  tag library</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">	&lt;%@ taglib prefix=&quot;bean&quot; uri=&quot;http://struts.apache.org/tags-bean&quot; %&gt;</pre></td></tr></table></div>

<h2> bean:include </h2>
<p><b>< bean:include >	</b>- It is used to load the response data from the dynamic application request and make it as available as a bean of type <i>string</i>.It performs internal dispatch to specified application component.this tag works similar to <i>< jsp:include> tag</i> except the response date is stored in page context instead of writing into output stream.</p>
<h2>Example Code for  bean:include </h2>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&#038;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<p>.
	</ul>
</p>
<p>In this example we do not need the ActionForm bean.</p>
<p>In this example we do not need the Action class.</p>
<p>No need to configure struts-config.xml file</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p>1.Create a simple jsp page <b>BeanIncludeTag.jsp</b> which illustrates the  bean:include tag by id and page attributes which specifies the jsp page that to be included.

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;%@page contentType=&quot;text/html&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%@taglib prefix=&quot;html&quot; uri=&quot;http://jakarta.apache.org/struts/tags-html&quot; %&gt;
&lt;%@taglib prefix=&quot;bean&quot; uri=&quot;http://jakarta.apache.org/struts/tags-bean&quot; %&gt;
&nbsp;
&nbsp;
&lt; html&gt;
    &lt; head&gt;
&nbsp;
        &lt; title&gt; Bean Include Tag &lt;/title&gt;
    &lt; head&gt;
    &lt; body bgcolor=&quot;#DDDDDD&quot;&gt;
        &lt; h1 &gt; bean:include tag example  &lt;/h1&gt;
&nbsp;
&nbsp;
&nbsp;
		   &lt; bean:include id=&quot;SampleJsp&quot; page=&quot;/Sample.jsp&quot;/&gt;
&nbsp;
            &lt; h3&gt; Displaying the Included Page Content&lt;/h3&gt;
			&lt; bean:write name=&quot;SampleJsp&quot; /&gt; &lt; br&gt;
&nbsp;
		  &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>2.Create any Sample jsp page which will be displayed here we used <b>Sample.jsp</b> page to be included.</p>
<p>3.Building and running the application</p>
<h4><b>Output</b></h4>
<p><b>Access page:
<pre>http://localhost:8084/beaninclude/BeanIncludeTag.jsp</pre>
<p></b></p>
<p><img src="images/2010/10/struts-beaninclude/struts-beaninclude-1.jpg" width="585" height="204"></p>
<h2>Struts Framework Articles</h2>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20?_encoding=UTF8&#038;node=13" target="_blank">Struts Books</a> from <a href="http://astore.amazon.com/javabeat-20" target="_blank">Java Books Store</a></li>
<li><a href="http://www.javabeat.net/articles/67-struts-20-introduction-and-validations-using-annotatio-1.html">Struts 2.0 Introduction and Validations using Annotations</a></li>
<li><a href="http://www.javabeat.net/articles/24-introduction-to-struts-actions-1.html">Introduction to Struts Actions</a></li>
<li><a href="http://www.javabeat.net/articles/69-whats-new-in-struts-20-struts-20-framework-1.html">What&#8217;s new in Struts 2.0?</a></li>
<li><a href="http://www.javabeat.net/articles/132-internationalization-and-taglibs-in-struts-12-1.html">Internationalization and Taglibs in Struts 1.2</a></li>
<p>	</u></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/10/struts-bean-include-tag-beaninclude/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
