Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

EL Operator Query

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
have you checked the book's Eratta?
 
Ashu Jain
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks a lot.
 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
  • 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 ]
 
Those are the largest trousers in the world! Especially when next to this ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic