aspose file tools*
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
Author

EL operator

putti don
Greenhorn

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);
request.setAttribute("integer",i);

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

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

2> String num="2";
request.setAttribute("num",num);

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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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

JSP.2.3.5.6 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: http://aspose.com/file-tools
 
subject: EL operator