This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes EL Operator Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EL Operator Query" Watch "EL Operator Query" New topic

EL Operator Query

Ashu Jain
Ranch Hand

Joined: Feb 24, 2008
Posts: 73

In HFSJ, Page 394. There is a question.

It says:-

String num = "2";
Integer i = new Integer(3);

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

Joined: Apr 20, 2002
Posts: 510
have you checked the book's Eratta?
Ashu Jain
Ranch Hand

Joined: Feb 24, 2008
Posts: 73
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

Joined: Aug 21, 2008
Posts: 83
In the 2nd Edition pg397 they have $(requestScope["integer"] ne ......

Errata for 1st Edition:

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}

Ashu Jain
Ranch Hand

Joined: Feb 24, 2008
Posts: 73
Thanks a lot.
Anton Golovin
Ranch Hand

Joined: Jul 02, 2004
Posts: 476
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 ]

Anton Golovin ( SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
I agree. Here's the link:
subject: EL Operator Query
jQuery in Action, 3rd edition