Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on EL

 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a doubts in EL.
Assume
<jsp:useBean class="foo.Dog" id="myDog">
<jsp:setProperty name="myDog" property="name" value=${list[1]}" />
</jsp:useBean>

Now, how does ${myDog.name and true} evaluate to false?

Can anybody explain me?

With regards,
Padma priya N.G.
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the value of list[1]?
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
It is not been given in the question. Can you tell how they have arrived at the answer?
Padma priya N.G.
 
Arnab Sinha
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that the entire question? I think there should be more to that question.
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which book/which question # please
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Priya,

It's very simple. Just common sense
In case of EL, all primitives are treated as Wrappers.
Did you get the answer to your query?

Regards,
Khushhal
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now, how does ${myDog.name and true} evaluate to false?


I am assuming that myDog.name evaluates to something that the EL (since the comparason operator 'and' is used) evaluates to false. So flase and true evaluates to false.


khushhal, would you explain further what you mean? I do not understand the point you are trying to make.
[ August 22, 2007: Message edited by: Michael Ku ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the "and" operator, myDog.name is coerced to Boolean.
If it is null or "" then it will return false.
Otherwise, it will call Boolean.valueOf. Check the API for Boolean.valueOf, and you'll see that :
. you get true if the String passed is "true" (not case sensitive)
. you get false otherwise

So unless your dog's name is "True", the result will be "false".
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for the explanantion.
With regards,
Padma priya N.G.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic