views:

295

answers:

2

In my JSP I'm required to compare to Objects to see if they are equal or not using the Object's equals method.

Is there a way to do this using the JSTL or another Tag Library?

(I am not allowed to use Scriptlets due to team rules.)

I tried to use the JSTL tag, but it only seems to use the == operator.

Any suggestions are appreciated.

Thank you for your time.

A: 

The J2EE 1.4 guide has an example of just that. You'll have to setup your once function lib, but it doesn't look hard.

sblundy
A better link would be: http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html#wp77078
Loki
+2  A: 

The JSP Expression Language operator == (or its alias, eq) performs comparison with the equals method, although some coercions are performed if one of the objects is a special type (BigDecimal, BigInteger, Double, Float, Long, Integer, Short, Byte, Character, Boolean, or String). You shouldn't need a tag for this, just ${a == b}. If that doesn't fit in your context, could you please post more information?

erickson