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.
Padma priya N.G.
Be the change you want to be - Mahatma Gandhi
Michael Ku
Ranch Hand
Joined: Apr 20, 2002
Posts: 510
posted
0
What is the value of list[1]?
Padma priya Gururajan
Ranch Hand
Joined: Oct 05, 2006
Posts: 411
posted
0
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
Joined: Jul 23, 2006
Posts: 72
posted
0
Is that the entire question? I think there should be more to that question.
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 ]
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".