aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt on EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt on EL" Watch "Doubt on EL" New topic
Author

Doubt on EL

Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 435
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
What is the value of list[1]?
Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 435
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
Is that the entire question? I think there should be more to that question.


SCJP 1.4: 91%<br />SCWCD 1.4: 85%
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
Which book/which question # please
khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

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


rgrds,
Khushhal
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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".


[My Blog]
All roads lead to JavaRanch
Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 435
Hi,
Thanks for the explanantion.
With regards,
Padma priya N.G.
 
wood burning stoves
 
subject: Doubt on EL