| < Day Day Up > |
|
The <logic:empty /> tag evaluates its body if either the scripting variable identified by the name attribute or a property of the named scripting variable is equal to null or an empty string. The <logic:empty /> tag has a body type of JSP and supports three attributes, described in Table 18.1.
Attribute | Description |
---|---|
name | Identifies the scripting variable being tested. If the property attribute is included in the tag instance, then the property of the named scripting variable is tested; otherwise, the named scripting variable itself is tested. (Required) |
property | Identifies the data member of the scripting variable to be tested. (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:empty /> tag is shown here:
<logic:empty name="user"> <forward name="login" /> </logic:empty>
In this example, we test the scripting variable user. If this variable is null or an empty string, then the body will be evaluated, which will result in the user being forwarded to the global forward login.
| < Day Day Up > |
|