users@glassfish.java.net

EL 3.0 doesn't behave in Glassfish 4 the same way as in the standalone API

From: Marcelo Cenerino <marcelocenerine_at_gmail.com>
Date: Mon, 19 Aug 2013 23:13:00 -0300

Hello,

I'm experimenting the new features of Expression Language 3.0, both in JSP
and using the standalone API. I noticed that some of the new stuff are not
behaving the same way in both places:

1- According to item 1.22 of EL spec, "A static field or static method of a
Javaclass can be referenced with the syntax classname.field, such as
Boolean.TRUE".
Doing so in the standalone API, it works as expected:

ELProcessor elp = new ELProcessor();
Object ret = elp.eval("Boolean.TRUE");
System.out.println("Output Value: " + ret);


Resulting: "Output Value: true"

or...

ELProcessor elp = new ELProcessor();
Object ret = elp.eval("(x -> Math.sqrt(x))(9)");
System.out.println("Output Value: " + ret);

prints: 9.0

However, when doing the same thing in JSP, nothing is printed:

${Boolean.TRUE}
${Integer.MAX_VALUE}
${Boolean.TRUE == true} // prints 'false'
${(x -> Math.sqrt(x))(9)}

2 - According to item 1.22.3 of EL spec, "A class name reference, followed
by arguments in parenthesis, such as Boolean(true) denotes the invocation
of the constructor of the class with the supplied arguments."
Doing so using the standalone API:

ELProcessor elp = new ELProcessor();
Object ret = elp.eval("StringBuilder('Java EE rocks')");
System.out.println("Output Value: " + ret);

Prints: Output Value: Java EE rocks

But, in JSP:

${StringBuilder('Java EE rocks')}

Results:


exception
org.apache.jasper.JasperException: javax.el.ELException: Expression uses
functions, but no FunctionMapper was provided root cause

*javax.el.ELException: Expression uses functions, but no FunctionMapper was
provided*

These expressions I have mentioned above wouldn't be supposed to work the
same way in JSP and in the standalone API? Is that a bug?

Thanks in advance.

-- 
*Marcelo Alves Cenerino*