Search code examples
jspelstring-concatenation

How to concatenate a String in Expression Language 3.0


i dont get EL 3.0 to work in Apache Tomcat 8. However EL 2.2 works perfect.

How i testet it: I made a JSP like that:

${'concat'+'test'}

Result: NumberFormatException: For input string: "concat"

EL 2.2 works fine:

${'concat'.concat('test')}

Result: concattest

This is my Webapp web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">

...

</web-app>

This is my global web.xml:

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  version="3.1">

...

    <init-param>
        <param-name>compiler</param-name>
        <param-value>ecj</param-value>
    </init-param>

Tomcat-Version: Apache Tomcat/8.0.47


Solution

  • Is it the correct syntax?

    If you check this SO question, BalusC is given examples for string concatenation. The one for EL 3.0 looks like this:

    ${'concat' += 'test'}