Logic Match Tag (...)

Match tag - We use this tag to evaluate the contents contained in the nested body parts of this tag if the specified value is an appropriate substring of the requested variable.

Logic Match Tag (<logic:match >...</logic:match
>)

match tag - We use this tag to
evaluate the contents contained in the nested body parts of this tag if the
specified value is an appropriate substring of the requested variable.

This tag matches the variable specified as a String
against the specified constant value. If the value is a substring then the
nested body content of this tag is evaluated.

Attributes of matchTag

Attribute Name

Description

cookie

The variable to be matched is the value of the
cookie whose name is specified by this attribute.

header

The variable to be matched is the value of the
header whose name is specified by this attribute. The name match is
performed in a case insensitive manner.

location

If not specified, a match between the variable
and the value may occur at any position within the variable string. If
specified, the match must occur at the specified location (either start
or end) of the variable string.

name

The variable to be matched is the JSP bean
specified by this attribute, if property is not specified,
or the value of the specified property of this bean, if property
is specified.

parameter

The variable to be matched is the first, or
only, value of the request parameter specified by this attribute.

property

The variable to be matched is the property (of
the bean specified by the name attribute) specified by this
attribute. The property reference can be simple, nested, and/or indexed.

scope

The bean scope within which to search for the
bean named by the name property, or "any scope"
if not specified.

value

The constant value which is checked for
existence as a substring of the specified variable.

Logic notMatch Tag (<logic:notMatch >...</logic:notMatch
>)

notMatch
- We use this tag to
evaluate the contents contained in the nested body parts of this tag if the
specified value is not a substring of the requested variable.

This tag matches
the variable specified by one of attributes (as a String) against the
specified constant value. If the value is not a substring the nested body
content of this tag is evaluated.

Attributes of notMatch Tag

Attribute Name

Description

cookie

The variable to be matched is the value of the
cookie whose name is specified by this attribute.

header

The variable to be matched is the value of the
header whose name is specified by this attribute. The name match is
performed in a case insensitive manner.

location

If not specified, a match between the variable
and the value may occur at any position within the variable string. If
specified, the match must occur at the specified location (either start
or end) of the variable string.

name

The variable to be matched is the JSP bean
specified by this attribute, if property is not specified,
or the value of the specified property of this bean, if property
is specified.

parameter

The variable to be matched is the first, or
only, value of the request parameter specified by this attribute.

property

The variable to be matched is the property (of
the bean specified by the name attribute) specified by this
attribute. The property reference can be simple, nested, and/or indexed.

scope

The bean scope within which to search for the
bean named by the name property, or "any scope"
if not specified.

value

The constant value which is checked for
existence as a substring of the specified variable.

Example Illustrating the use of the Match <logic:match
>
and the notMatch <logic:notMatch > logic tags.

Here you will learn to use the Struts Logic tags.
We will cover an example that will show a comparison between the two
logic tags (ie..<logic:match > and the <logic:notMatch>).

To build and deploy the application go to Struts\Strutstutorial
directory and type ant on the command prompt. This will deploy the application.
Open the browser and navigate to the InputLogic.jsppage. Your browser
displays the following page.

Writing text including "amit" and excluding
"abc" to the InputLogic.jsp page
displays the working of the match Logic tag <logic:match > and
the notMatch Logic tag <logic:notMatch > .

It displays the following to the out.jsp
page

Writing text including "amit" and
"abc" to the InputLogic.jsp page
displays the working of the match Logic tag <logic:match > and
the notMatch Logic tag <logic:notMatch > .