Two Laptop Bag*
The moose likes JSP and the fly likes EL arithmetic question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "EL arithmetic question" Watch "EL arithmetic question" New topic
Author

EL arithmetic question

igor ganapolsky
Greenhorn

Joined: Apr 14, 2009
Posts: 6
Given this servlet code snippet:
String num = “2”;
request.setAttribute(“num”, num);
Integer i = new Integer(3);
request.setAttribute(“integer”, i);


What prints for the following EL?
${requestScope[“integer”] ne 4 and 6 le num || false}

I thought it prints true because: true and false or false = true

But in the book O'Reilly Head First Servlets and JSP (2nd Edition) they state that it prints false! I just want to make sure I'm not the one who is mistaken here.

Thanks,
Igor
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
it prints false since 6 <= 2 is false


JDBCSupport - An easy to use, light-weight JDBC framework -
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016

I thought it prints true because: true and false or false = true


It does?

true and false or false
--> (true and false) or false
--> false or false
--> false.

igor ganapolsky
Greenhorn

Joined: Apr 14, 2009
Posts: 6
Thanks, I got mixed up.
igor ganapolsky
Greenhorn

Joined: Apr 14, 2009
Posts: 6
Sebastian Janisch wrote:it prints false since 6 <= 2 is false

The EL expression evaluates to false, but not only for the reason you stated.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EL arithmetic question
 
Similar Threads
EL operator
EL Operator Query
Validate ID through RegEx
Help me in EL expression question HFSJ Book page 393
Doubt in EL