This question already has an answer here:
- How to concatenate a String in EL? 5 answers
Apparently, you cannot use the normal + operator to append strings in jsp...at least its not working for me. Is there a way to do it? Fragment of my code that is relevant...
${fn:length(example.name) > 15 ? fn:substring(example.name,0,14) + '...' : example.name} // does not work because of + operator
EL does not know a string concatenation operator. Instead, you would just inline multiple EL expressions together. The
+
operator is in EL exclusively a sum operator for numbers.Here's one of the ways how you could do it:
Another way is to use an EL function for this wherein you can handle this using pure Java. For an example, see the "EL functions" chapter near the bottom of my answer in Hidden features of JSP/Servlet. You would like to end up as something like:
with