Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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 ]
 
no wonder he is so sad, he hasn't seen this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic