• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt on EL

 
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which book/which question # please
 
Ranch Hand
Posts: 242
Mac Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for the explanantion.
With regards,
Padma priya N.G.
 
reply
    Bookmark Topic Watch Topic
  • New Topic