This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

EL Operator Query

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In HFSJ, Page 394. There is a question.

It says:-

String num = "2";
request.setAttribute("num",num);
Integer i = new Integer(3);
request.setAttribute("integer",i);

What would be value of expression
${requestScope[integer] ne 4 and 6 le num || false}
Answer is "false"

But my query is "how is this evaluated". As per my understanding,
requestScope is a map of attributes in request scope and [integer] is not a string literal - it should have been evaluated.

${requestScope[integer] --> requestScope[i]

[integer] is not in quotes. How it got evaluated.

Unable to understand. Please help
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have you checked the book's Eratta?
 
Ashu Jain
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope. Where do we see book's Erratum. I have HFSJ 1st Edition.

Please help. I got confused with the explanation in the example.
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the 2nd Edition pg397 they have $(requestScope["integer"] ne ......

Errata for 1st Edition:

http://oreilly.com/catalog/9780596005405/errata/

Under cofirmed errors:

(393) 3rd item of "What prints for each of these?";
${requestScope[integer] ne 4 and 6 le num || false}
should read:
${requestScope["integer"] ne 4 and 6 le num || false}


Rufus.
 
Ashu Jain
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.
 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
integer is a key in the Map in request scope. You can include it in quotation marks or not in quotation marks, it will be evaluated just the same in this case.



This would be

(3 not equal to 4) and ((6 less than or equal to 2) or false), right?

true and false = false.

I don't remember the precedence, is it and or ||? But in either case, it is false.
[ November 18, 2008: Message edited by: Anton Golovin ]
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic