• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL Operator Query

 
Ashu Jain
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
 
Michael Ku
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.
 
Rufus Addis
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.
 
Anton Golovin
Ranch Hand
Posts: 476
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic