Skip to main content
This revision made January 06, 2012 21:29, by Kin-man Chung
« earlier revision revert to this « later revision


Several operators are introduced in EL 3.0.

String Concatenation


 A & B
  1. Coerce A and B to String. Note: according 1.18.2, a null is coerced to "".
  2. Return the concatenated string of A and B.

Operator Precedence

The precedence for & is lower than "+" and "-" (binary) but higher than logical operators (== != etc.). It is left-associative, i.e. a & b & c is (a & b)&c.


1 & 2 returns "12"

"1" & "2" returns "12"



expr-a = expr-b

  • If expr-a is an identifier (name-a) and name-a is an EL variable (i.e. it is defined in the VariableMapper), or if name-a is not resolved by the ELResolver
    • Set name-a in the VariableMapper with the ValueExpression for expr-b, without evaluation.
    • Evaluate expr-b to value-b.
  • Else
    • Evaluate expr-b to value-b.
    • Evaluate expr-a, up to (but not including) the last property resolution.
    • If expr-a is a . or [] operator, evaluate the base to base-a, and the property to prop-a.
      • If base-a is null, throw a BeanNotFoundException.
      • If prop-a is null, throw a PropertyNotFoundException.
    • Invoke ValueExpression.setValue for expr-a: expr-a.setValue(context, value-b);
  • If ValueEpxression.getValue was called to initiate this expression evaluation, return value-b. In other words, the result of evaluating the assignment is the value of the right hand side.
  • If ValueExpression.setValue was called to initiate this expression evaluation, throw a PropertyNotWritableException. An assignment expression cannot be the target of setValue.

Note that EL variables are bound at parse time, so their assignment in an expression only takes effect after the expression is evaluated. This can lead to some unexpected behaviors. For example, consider the following.

  elp = new ELProcessor();
  elp.setVariable("x", "10");
  int n = elp.getValue("(x = 20) + x}";

The value of n is 30 instead of 40, because the value of x is 10 when the expression is parsed.

Operator Precedence

It is lower than the ?: operator, but higher than the semicolon operator. It is also right-associative, i.e. a = b = c is a = (b = c).


  x = a.b
  If x does not exist then same as calling defineVariable("x", "a.b");
  x.y = a.b
  Set x.y = a.b. Error if x does not exist.

SemiColon Operator


expr-a ";" expr-b

  • expr-a is evaluated and the resulting value is discarded.
  • If ValueEpxression.getValue was called to initiate this expression evaluation, expr-b is evaluated and the resulting value is returned.
  • If ValueExpression.setValue was called to initiate this expression evaluation, expr-b.setValue is called.

Operator Precedence

The semiColon operator has the lowest precedence of all operators.


Difference compared to previous revision
<span>expr-a ";" expr-b *expr-a is evaluated and the resulting value is discarded. *<span style="text-decoration:line-through;color:red">A</span><span style="text-decoration:underline;color:green">If</span> <span style="text-decoration:line-through;color:red">c</span><span style="text-decoration:underline;color:green">V</span>al<span style="text-decoration:line-through;color:red">l t</span><span style="text-decoration:underline;color:green">ueEpxressi</span>o<span style="text-decoration:line-through;color:red"> </span><span style="text-decoration:underline;color:green">n.</span>getValue <span style="text-decoration:line-through;color:red">or </span><span style="text-decoration:underline;color:green">wa</span>s<span style="text-decoration:line-through;color:red">etV</span><span style="text-decoration:underline;color:green"> c</span>al<span style="text-decoration:line-through;color:red">u</span><span style="text-decoration:underline;color:green">l</span>e<span style="text-decoration:underline;color:green">d</span> <span style="text-decoration:underline;color:green">t</span>o<span style="text-decoration:underline;color:green"> i</span>n<span style="text-decoration:underline;color:green">itiate</span>e on <span style="text-decoration:line-through;color:red">(</span> <span style="text-decoration:underline;color:green">this </span>expr<span style="text-decoration:line-through;color:red">-</span><span style="text-decoration:underline;color:green">ession ev</span>a<span style="text-decoration:line-through;color:red">;</span><span style="text-decoration:underline;color:green">luation,</span> expr-b<span style="text-decoration:line-through;color:red">)</span> is e<span style="text-decoration:line-through;color:red">qui</span> expr-b is eval<span style="text-decoration:underline;color:green">uat</span>e<span style="text-decoration:underline;color:green">d a</span>n<span style="text-decoration:underline;color:green">d </span>t<span style="text-decoration:underline;color:green">he</span> <span style="text-decoration:underline;color:green">resul</span>valent t<span style="text-decoration:line-through;color:red">o</span>t<span style="text-decoration:underline;color:green">ing</span> <span style="text-decoration:underline;color:green">value is re</span> t<span style="text-decoration:line-through;color:red">h</span>t<span style="text-decoration:underline;color:green">urn</span>e<span style="text-decoration:underline;color:green">d. *If</span> <span style="text-decoration:underline;color:green">ValueExpre</span>s<span style="text-decoration:underline;color:green">sion.setV</span>e sa<span style="text-decoration:line-through;color:red">m</span>a<span style="text-decoration:underline;color:green">lu</span>e <span style="text-decoration:underline;color:green">was </span>call<span style="text-decoration:underline;color:green">ed to initiate thi</span>s <span style="text-decoration:underline;color:green">expression evalua</span>t<span style="text-decoration:underline;color:green">i</span>o<span style="text-decoration:underline;color:green">n,</span> expr-b<span style="text-decoration:underline;color:green">.setValue is called</span>. ===Operator Precedence=== The semiColon operator has the lowest precedence of all operators. ===Example=== <span>
Please Confirm