logic:present

 < Day Day Up > 



<logic:present />

The <logic:present /> tag evaluates its body if the variable specified by any one of the cookie, header, name, parameter, or property attributes is present in the applicable scope. The <logic:present /> tag has a body type of JSP and supports eight attributes, described in Table 18.13.

Table 18.13: <logic:present /> Tag Attributes

Attribute

Description

cookie

Specifies an HTTP cookie to be used as the variable being tested for existence. (Optional)

header

Specifies a case-insensitive HTTP header to be used as the variable being tested for existence. (Optional)

name

Defines a scripting variable to be used as the variable being tested for existence. (Optional)

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 tested for existence. (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)

role

Used to determine if the currently authenticated user belongs to one or more named roles. If more than one role is listed, then they must be separated by commas. (Optional)

user

Used to determine if the currently authenticated user has the specified name. (Optional)

An example of using the <logic:present /> tag is shown here:

 <logic:present parameter="username">   Welcome <%= username %>. </logic:present > 

In this example, we test for the existence of the request parameter username. If the username parameter is part of the request, then the tag's body will be evaluated.



 < Day Day Up > 



Professional Jakarta Struts
Professional Jakarta Struts (Programmer to Programmer)
ISBN: 0764544373
EAN: 2147483647
Year: 2003
Pages: 183

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net