wood burning stoves*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Confusion in EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Confusion in EL" Watch "Confusion in EL" New topic
Author

Confusion in EL

chou hung
Greenhorn

Joined: Jan 07, 2008
Posts: 2
Hi,

Given the code as below:



The result is true.

Since EL treats null object as false in logical expression and map.c actually exists, does anyone have idea why the result is true?


Chou Hung<br />SCJP 1.4<br />SCWCD 5
Dee Brown
Ranch Hand

Joined: Jun 14, 2008
Posts: 94
I believe it is because ${requestScope.map.c} returns "42". Since "42".equalsIgnoreCase("true") == false, ${not requestScope.map.c} == true.
chou hung
Greenhorn

Joined: Jan 07, 2008
Posts: 2
Hi Dee,

Thanks for the reply. That makes sense.
sudhakar karnati
Ranch Hand

Joined: May 03, 2007
Posts: 93
I believe it is because ${requestScope.map.c} returns "42". Since "42".equalsIgnoreCase("true") == false, ${not requestScope.map.c} == true.


Sorry i could not understand the explanation above(in Bold)..if i had missed any topic related to this in HFSJ please tell me the page number so that i can go back and read once again..

Thanks & Regards,
Sudhakar Karnati
Dee Brown
Ranch Hand

Joined: Jun 14, 2008
Posts: 94
In the statement, "${not requestScope.map.c}", the "not" operator coerces the evaluation of "requestScope.map.c" (i.e. "42") to a boolean. In simple terms, a boolean X is true when X.equalsIgnoreCase("true") is true. Therefore, since
"42".equalsIgnoreCase("true") == false, its negation (i.e. ${not requestScope.map.c}) is true.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Confusion in EL