| < Day Day Up > |
|
The <logic:equal /> tag evaluates its body if the variable specified by any one of the attributes cookie, header, name, parameter, or property equals the constant value specified by the value attribute. The <logic:equal /> tag has a body type of JSP and supports seven attributes, described in Table 18.3.
Attribute | Description |
---|---|
value | Identifies the constant value to which the scripting variable will be compared. (Required) |
cookie | Specifies an HTTP cookie to be used as the variable being compared to the value attribute. (Optional) |
header | Specifies an HTTP header to be used as the variable being compared to the value attribute. (Optional) |
name | Specifies a scripting variable to be used as the variable being compared to the value attribute. (Required) |
property | Specifies the data member of the scripting variable to be tested. (Optional) |
parameter | Specifies an HTTP parameter to be used as the variable being compared to the value attribute. (Optional) |
scope | Defines the scope of the bean specified by the name attribute. If the scope attribute is not specified, then the tag will search for the bean in the scopes, in the order of page, request, session, and application. (Optional) |
An example of using the <logic:equal /> tag is shown here:
<logic:equal name="user" property="age" value="<%= requiredAge %>"> You are exactly the right age. </logic:equal>
In this example, we test the age data member of the scripting variable user. If this data member equals the value stored in the requiredAge scripting variable, then the tag's body will be evaluated.
| < Day Day Up > |
|