{"id":192,"date":"2007-09-06T00:00:00","date_gmt":"2007-09-06T00:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=192"},"modified":"2007-09-06T00:00:00","modified_gmt":"2007-09-06T00:00:00","slug":"Struts Logic Tags: An Introduction","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=192","title":{"rendered":"Struts Logic Tags: An Introduction"},"content":{"rendered":"<p><P><FONT color=#0000ff size=3><I><B>Struts logic tags are conditional tags that replaces scriptlets in the jsp files.<\/B><\/I><\/FONT><\/P><br \/>\n<H4><FONT color=#000080 size=3>This tag library contains tags that do the following things :<BR>&nbsp;&nbsp;&nbsp; conditional generation of the output text,<BR>&nbsp;&nbsp;&nbsp; generate iterations to output the text,<BR>&nbsp;&nbsp;&nbsp; application flow management,<BR>&nbsp;&nbsp;&nbsp; matching strings and substrings&#8230;<BR><\/FONT><\/H4><br \/>\n<P><FONT color=#000080 size=4>Logic tags available in the Struts Framework<\/FONT><\/P><br \/>\n<DIV align=left><br \/>\n<TABLE borderColor=#ffffcc cellPadding=0 width=\"93%\" bgColor=#ffffcc border=1><br \/>\n<TBODY><br \/>\n<TR><br \/>\n<TD width=\"25%\"><B><FONT color=#000080 size=4>Tag Name<\/FONT><\/B><\/TD><br \/>\n<TD width=\"75%\"><B><FONT color=#000080 size=4>Description<\/FONT><\/B><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>empty&nbsp;<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>If the requested variable is either null or an empty string then the nested body content of this tag is evaluated<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>equal&nbsp;<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>If the requested variable is equal to the specified value then the nested body content of this tag is evaluated<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>forward&nbsp;<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>It forwards the control to the page specified by the specified ActionForward entry.<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>greaterEqual<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>If the value of the requested variable is greater than or equal to the specified value then the nested body content of this tag is evaluated<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>greaterThan&nbsp;<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>If the value of the requested variable is greater than the specified value then the nested body content of this tag is evaluated<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>iterate&nbsp;<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>It repeats the nested body content of this tag over a specified collection.<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>lessEqual&nbsp;<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>If the value of the requested variable is less than or equal to the specified value then the nested body content of this tag is evaluated<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>lessThan<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>If the value of the requested variable is less than the specified value then the nested body content of this tag is evaluated<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>match<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>Evaluates the nested body content of this tag if the specified value is an appropriate substring of the requested variable.<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>messagesNotPresent<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>If the specified message is not present in the request then it generates the nested body content of this tag .<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>messagesPresent<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>If the specified message is present in this request then it generates the nested body content of this tag .<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>notEmpty<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>If the requested variable is neither null nor an empty string nor an empty java.util.Collection (tested by the isEmpty() method on the java.util.Collection interface) then the nested body content of this tag is evaluated<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>notEqual<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>If the requested variable is not equal to the specified value then the nested body content of this tag is evaluated<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>notMatch<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>If the specified value is not an appropriate substring of the requested variable then the nested body content of this tag is evaluated&nbsp;<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>notPresent<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>If the specified value is not present in the request then it generates the nested body content of this tag .<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>present<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>If the specified value is present in the request then it generates the nested body content of this tag&nbsp;<\/FONT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD width=\"25%\"><FONT color=#000080 size=4>redirect<\/FONT><\/TD><br \/>\n<TD width=\"75%\"><FONT color=#000080>It renders an HTTP Redirect request.<\/FONT><\/TD><\/TR><\/TBODY><\/TABLE><\/DIV><br \/>\n<P><FONT color=#000080 size=3>Struts logic tags uses <B>equal, greaterEqual, greaterThan, lessEqual, lessThan, notEqual<\/B> tags to compare the values. There are rules that must be&nbsp; followed :<\/FONT><\/P><br \/>\n<UL><br \/>\n<LI><FONT color=#000080 size=3>Initially the specified variable needed to be compared is examined (whether it can be converted to a <CODE>double<\/CODE> or to a <CODE>long<\/CODE>). Then a&nbsp; numeric (either floating point or integer) type comparison is done. If numeric conversion fails than a String comparison is performed.<\/FONT><br \/>\n<LI><FONT color=#000080 size=3>The variable to be compared is retrieved from the request attribute(s)&nbsp; that may be a <CODE>cookie<\/CODE>, <CODE>header<\/CODE>, <CODE>name<\/CODE>, <CODE>parameter<\/CODE> or <CODE>property<\/CODE> available to the specified tag. This variable is then converted to the appropriate type needed for the comparison..<\/FONT><br \/>\n<LI><FONT color=#000080 size=3>If the variable or property to be compared returns null, it is converted into a zero-length string before the comparison occurs.<\/FONT><br \/>\n<LI><FONT color=#000080 size=3>If the comparison logic returns a <CODE>true<\/CODE> value then only the specific comparison is performed and subsequently the nested body content is evaluated .<\/FONT> <\/LI><\/UL><br \/>\n<P><FONT color=#000080 size=3>Struts logic tags&nbsp; can also do the substring matching using the tags (<B><CODE>match<\/CODE>, <CODE>notMatch<\/CODE><\/B>). There are rules that must be&nbsp; followed :<\/FONT><\/P><br \/>\n<UL><br \/>\n<LI><FONT color=#000080 size=3>The variable to be compared is retrieved from the request attribute(s)&nbsp; that may be a <CODE>cookie<\/CODE>, <CODE>header<\/CODE>, <CODE>name<\/CODE>, <CODE>parameter<\/CODE> or <CODE>property<\/CODE> available on this tag. Then this variable is converted to a String, if necessary.<\/FONT><br \/>\n<LI><FONT color=#000080 size=3>If the retrieval of the variable fails or it contains a null value then a request time exception is thrown.&nbsp;&nbsp;<\/FONT><br \/>\n<LI><FONT color=#000080 size=3>The existence of the variable as a substring is examined at the position specified by the <CODE>location<\/CODE> attribute Location can be specified at the beginning (if location is set to <CODE>start<\/CODE>), at the end (if location is set to <CODE>end<\/CODE>), or anywhere (if location is not specified).<\/FONT> <\/LI><\/UL><br \/>\n<P><FONT color=#000080 size=3>A <CODE><B>JspException<\/B><\/CODE> is thrown at runtime if any tag is utilized incorrectly or any invalid combination of tag attributes are used. To process the actual exception that caused the problem,&nbsp; a request attribute under key <CODE><B>org.apache.struts.action.EXCEPTION<\/B><\/CODE>&nbsp; is passed to the error page.<\/FONT><\/P><br \/>\n<P><FONT color=#000080 size=3>In the subsequent section we will show you the examples of these tags.<\/FONT><\/P><br \/>\n<DIV><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Struts logic tags are conditional tags that replaces scriptlets in the jsp files. This tag library contains tags that do the following things :&nbsp;&nbsp;&nbsp; conditional generation of the output text,&nbsp;&nbsp;&nbsp; generate iterations to output the text,&nbsp;&nbsp;&nbsp; application flow management,&nbsp;&nbsp;&nbsp; matching strings and substrings&#8230; Logic tags available in the Struts Framework Tag Name Description empty&nbsp; If &hellip; <a href=\"https:\/\/www.strongd.net\/?p=192\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Struts Logic Tags: An Introduction<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-192","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=192"}],"version-history":[{"count":0,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/192\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}