• 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 about Unknown Attributes in EL

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
i have doubt in EL expressions like these :
${7<foo}. In the above expression, if foo is a unknown attribute, hence foo will take default value. In this case, whether container will provide default value for arithmethic expression or logical expression.
when this expression is run, result is false.
please tell me how container provide default value.

Thanks and Regards,
 
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here foo wll be given a default value of 0

Since its a logical expression involving numeric values..

So 7 < 0 gives result as false..
 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you mean " Default value will be given by container based on the type of the other operand".
 
Ranch Hand
Posts: 105
Android Mac Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you run this piece of code:



The output will be something like this



You can see that the unknown var "foo" is not set to 0 as default and "-1 < foo" still results in false. I think it rather has to do with the fact that the retrieval of the unknown foo attribute returns a null-value somewhere, and the EL expression evaluator returns false as a default if e.g. an integer is compared to an unknown / null value (but don't quote me on this ;-)
[ October 30, 2006: Message edited by: Johan Pelgrim ]
 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys for your attempts.
But, in HFJS, it is mentioned that if a EL expression is having unknown variable, default value of false will be assigned to it if the expression is logical expression. If the expression is arithmetic expression, default value of 0 will be assigned to unknown variable.

is it really happening like this?

please put some lights on this concept.

Thanks and Regards,
 
Johan Pelgrim
Ranch Hand
Posts: 105
Android Mac Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe it should be read as "if an EL expression uses an unknown variable", then the expression results in "false" (if it's a logical expression), or "0" (if it's an arithmetic expression)?
[ October 30, 2006: Message edited by: Johan Pelgrim ]
 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are right.
Thanks Johan.
 
Johan Pelgrim
Ranch Hand
Posts: 105
Android Mac Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you maybe post the specific section from the HF book which is confusing? (Because I don't have that book)
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Even i replied on the basis of that book...

Sorry about the post..
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic