The Logic Tag Library provides a rich set of tags for cleanly implementing simple conditional logic in JSPs. With these tags you can wrap content that will be processed only when a particular condition is true. For example, you can use the equal tag to wrap content that is conditionally processed based on whether two specified values are equal or not. The following snippet illustrates this:
<logic:equal name="resultCount" value="0"> Search returned no results. </logic:equal>
If the object specified by the name attribute is equal to "0", as specified by the value attribute, then the content between the starting and ending equal tags will be processed. Otherwise, the content will be ignored.
Note that the Logic Library has three tags that are not used for conditional logic: the forward tag, the iterate tag, and the redirect tag. The forward tag is used to look up a forward from the Struts configuration file and redirect to it. The iterate tag is used to wrap content that should be processed for each element of a collection, and the redirect tag is used to send an HTTP redirect response to a browser, causing it to load another page.
Many of the tags in this library have JSTL equivalents that should be used in lieu of these tags. See Chapter 17 for more information on using JSTL with Struts and the list of Struts tags that can be replaced with JSTL equivalents.