BBJSP CORE:Compare Tag (Deprecated)

The BBJSP system is deprecated. For new development, use BBxServlet.

Description

In BBj 16.0 and higher, the compare tag can be used within a BBJSP Page to compare two string values and when they meet the specified comparison type then the body of the tag will be processed.

If the values are numeric then a standard numeric comparison will be applied otherwise String comparison will be used; for example:

  • "A" <"aa"
  • "1" <"10"

Attributes

Attribute Name

Description

Required

Expression

Data Type

type

specified how to compare value1 against value2.
The following values can be used:

  • EQ - equal
  • NE - not equal
  • GT - greater than
  • LT - less than
  • GE - greater than or equal
  • LE - less than or equal

true

false

String

value1

the first value used in the comparison

true

true

Object

value2

the second value used in the comparison

true

true

Object

Remarks

The Core Tag Library library needs to be referenced in the BBJSP Page

The values will be compared as numeric if possible otherwise a string comparison will be used

Example

<!DOCTYPE html/>

<%-- Import the tag library --%>
<%@ taglib uri='/WEB-CFG/tld/core.tld' prefix='c' %>

<html>
<head> 
<title><c:compare></title> 
</head>
<body>
<form method='GET'>
COMPARE :
<input name='value1' placeholder='value 1' value='${param["value1"]}' />
<input name='value2' placeholder='value 2' value='${param["value2"]}' />
<input type='submit' />
</form>

<c:compare type='GT' value1='${param["value1"]}' value2='${param["value2"]}' >
${param["value1"]} is Greater than ${param["value2"]}
</c:compare>

<c:compare type='LT' value1='${param["value1"]}' value2='${param["value2"]}' >
${param["value1"]} is Less than ${param["value2"]}
</c:compare>

<c:ifnotempty data='${param["value1"]}'>
<c:compare type='EQ' value1='${param["value1"]}' value2='${param["value2"]}' >
${param["value1"]} is Equal to ${param["value2"]}
</c:compare>
</c:ifnotempty>
</body>
</html>

See Also

BBJSP

Core Tag Library