BBJSP Expression Language (Deprecated)

The BBJSP system is deprecated. For new development, use BBxServlet.


In BBj 16.0 and higher, the BBJSP framework allows the embedding of expressions within a BBJSP Page to render data from various sources.

Developers can embed data directly into the generated HTML by way of the Expression Language. Expressions are placed within the expression tag like this:

${ expressions }
<%= expressions %> 

When you specify an attribute value in a tag, rather than using a string literal, you can use an expression to access other data. For example:

<c:set var='age' value='${foo}' /> 

The data within the expression is evaluated when the page is rendered to the client.

Read Data Structures

Data can also be extracted from BBj objects where the object defines public fields. For example, lets assume you have an object called foo which has a field called woo, you can access the value of foo.woo like this:


This same syntax can be applied to Maps and additionally to the build-in elements SESSION, PARAM, HEADER and BBJSPSESSION allowing you to do things like:

  • ${session['attributeName']}
  • <m:loadUser id="${param['username']}"/>
  • <c:out value="${header['user-agent']}"/>
  • <c:if test="${bbjspsession['isOK']}"/>
  • <c:if test="${bbjspsession['isOK']}"/>

In the examples above we're looking for a field in the PARAM and HEADER objects but we specified the field name using a literal expression, ie. it was a quoted string; but what if you want to access the field dynamically? Well, you can do that too like this:

<c:out value="${header[headerName]}"/>

Note the headerName was not enclosed in quotes so it must first be created. You can see this working in the Expression Language demo.

Direct vs Indirect references in Expressions

An expression takes the form of ${element[member]} whereby the element should exist in the BBjspPageContext and should contain the named member. The element could be a BBJSP Widget from the page, a named BBjspHashMap or some other Object. When referencing a member you can either specify name directly by enclosing it in quotes like this: ${foo["woo"]} or indirectly like this: ${foo[woo]}. When using an indirect reference, the name you use as the reference should evaluate to a String stored in the BBjspPageContext and your element must gave the following method defined to perform the lookup:

public Object get(BBjString name)

Math in Expressions

EL expressions can use parentheses to group subexpressions. For example, ${(1 + 2) * 3} equals 9, whereas ${1 + (2 * 3)} equals 7.

Data can be extracted from records and applied in an expression calculation like this:

Credit remaining: <c:out value="${customer['limit'] - customer['balance']}"/>

See Also





Core Tag Library