32

What does ${} means in JSP? For example,

<c:if test="${!empty cookie.lang}">
    <fmt:setLocale value="${cookie.lang.value}" />
</c:if>
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
brownmamba
  • 755
  • 1
  • 8
  • 16

4 Answers4

24

It is an EL expression basically it outputs the value that result from evaluating the expression, to put it simply, it allows you to access the values of the properties of your Java beans using "dots" instead of using getters and setters, using it you can access instances of beans that can be in session, request, or page scope.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
RRoman
  • 741
  • 9
  • 19
11

It is Expression Language. Before EL evolved, the same purpose was achieved by using scriptlets <%=..%>The primary purpose of using this syntax is to avoid scriptlets in jsp. Scriptlets and the enclosed java code is considered bad practise because jsps are not 'supposed' to have java code. At least that is the theory.

Victor
  • 16,609
  • 71
  • 229
  • 409
4

The ${} referes to EL expressions. You usually access some managed beans on the server via the EL expression.

Jan Zyka
  • 17,460
  • 16
  • 70
  • 118
1

It's indeed an Expression Language expression. A great resource is the tag on this site, especially the Expression Language wiki is a must read in my opinion.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102