permaculture playing cards
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes EL operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EL operator" Watch "EL operator" New topic

EL operator

putti don

Joined: Jul 28, 2005
Posts: 20
Hi Everyone,

Could anyone please explain me how the following works?

1> Servlet code:
Integer i=new Integer(3);

JSP:${integer le 12}....answer is true.

My doubt is how Integer object is converted to primitive int?

2> String num="2";

JSP: ${num > 3}......answer is false
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

I think that you should have a look at the spec the check how the convertions behave. Here is a part of it :

JSP. A {<,>,<=,>=,lt,gt,le,ge} B

� If A or B is String coerce both A and B to String, compare lexically
This is your second example

� If A is Comparable, then:
If A.compareTo (B) throws exception, error.
Otherwise use result of A.compareTo(B)
This is your first example (Integer implements Comparable)

[My Blog]
All roads lead to JavaRanch
I agree. Here's the link:
subject: EL operator
It's not a secret anymore!