This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL boolean operator precedence (error in HF?)

 
Jim Olsen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using HF Servlets & JSP to learn about this stuff. On page 393 of the book, there's an exercise where the reader is to evaluate some EL expressions. Two of the expressions are essentially:



On page 394, one of the hand-written notes asks the reading to determine the precedence rules. It then goes on to say precedence is just left to right. I believe you cannot determine precedence from these two examples, so I came up with a new expression to test for precedence just to double-check what the book says.



When I loaded the JSP with tomcat5, it printed "true" indicating the "and" operator has higher precedence.

Is this an error in the book, an error in the implementation of Tomcat, or an error in my comprehension of the material? Which precedence rule should I remember for the exam?

[ March 17, 2005: Message edited by: Jim Olsen ]
[ March 17, 2005: Message edited by: Jim Olsen ]
 
Nitish Bahadur
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Operator precedence works from left to right. Additionally, access operators, such as . and [], have a higher precedence than arithmetic operators, which have a higher precendence than logical operators.

In the logical operators 'and' is higher(evaluate first) than 'or'. Refer to JSP 2.3.10 for details.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic