The dsp:containsEJB
tag checks whether a specific EJB exists in a Collection and saves the Boolean result to the var
attribute. EJBs require their own comparison tag because two EJBs instances might appear identical but differ in address, and therefore, fail a comparison that should have passed. Using the dsp:containsEJB
tag ensures that only the object’s primary keys are factored into the comparison, and the object address is ignored.
Attributes
TagVariable:varorid(Required)
You must define an EL variable or scripting variable:
Attribute | Description |
---|---|
| Names an EL variable. When you use |
| Names a scripting variable, which scriptlets and expressions can access at runtime. |
VariableScope:scope
The scope
attribute determines what resources can access the named EL variable. Options include: page
, request
, session
, or application
. Omitting this attribute causes the default, page
, to be used.
EJBCriteria:ejb(Required)
The ejb
attribute holds the EJB that is being checked for inclusion in the Collection identified by the values
attribute. This tag determines whether there is a match between the EJB held in this attribute and an entry in the values
attribute Collection.
ItemtoBeSearched:values(Required)
The values
attribute holds the Collection in which you want to search for a specific EJB value. This attribute permits EJB-containing items of the following data types: array, Enumeration, Iterator, Collection and Map. When values
is set to a Map, the Map key is used for comparison.
Example
<dsp:getvalueof bean="Student_01" var="student">
<dsp:containsEJB var="seniorReminder" values="${student.class}" ejb="senior"/>
<c:choose>
<c:when test="${seniorReminder}">
Don't forget to order your cap and gown!
</c:when>
</c:choose>
</dsp:getvalueof>
In this example, the dsp:containsEJB
tag determines whether senior
is an EJB in Student_01.class
. If it is, Don't forget to order your cap and gown!
displays.