This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL operator

 
putti don
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic