JSP: EL String concatenation
June 16, 2010 16:06:51 Last update: June 16, 2010 16:06:51
The
+ operator which is used in Java to concatenate strings does not work in JSP. In JSP, you simply string them together without the + operator.
<!DOCTYPE html> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> <html> <head> <title>Test Page</title> </head> <body> <c:set var="majorVersion" value="1"/> <c:set var="minorVersion" value="03"/> Full version: <c:out value="${majorVersion}.${minorVersion}"/> <br> <c:set var="fullVersion" value="${majorVersion}.${minorVersion}"/> <c:if test="${'1.03' == fullVersion}"> Can't use concatenation directly in test condition, set variable fullVersion first! </c:if> </body> </html>
Easy email testing with http://www.ximailstop.com