6.1 Understand the four data scopes

PageContext extends JspContext and contains static variables for scope:

  • PageContext.SESSION_SCOPE
  • PageContext.REQUEST_SCOPE
  • PageContext.PAGE_SCOPE

In EL, these correspond to implicit objects:

  • applicationScope
  • sessionScope
  • requestScope
  • pageScope

6.2 Understand and use EL dot and array access operators with Java Beans, arrays, and collections

dot access operator

  • left must be a map or bean
  • right must be a map key or bean property. It must follow normal Java naming rules for identifiers.

array access operator

  • Using [], left can be any type, not just a bean or map. E.g. map, bean, list, array
  • right can be any identifier . e.g. Map key or a bean property, or an index into a List or array.


${left["0"]} // string index converted to int for arrays and lists (tricky when arithmetic is involved)
// beans and maps can use [] or .
// name is evaluated to a key, not a value. the evaluated key is used to retrieve a value
// el can be used for nested expressions
// invalid
${musicList.1} // but this is okay: ${musicList["1"]}

6.3 Understand and use EL implicit objects

EL implicit objects are not the same as JSP scripting objects. All but pageContext is a map. These objects are used to access attributes, not properties (i.e. variables, not methods).

Remember these confusing aspects:

  • attributes = member variables
  • properties = methods (not accessible by EL using implicit objects)
  • objects added through scripting are not available to EL, unless the following is used: pageContext.setAttribute("x", x, PageContext.X_SCOPE) or request.setAttribute("ten", "10"), etc.
  • EL will find the name variables by searching through all scopes automatically, starting with page scope.

List of all implicit objects

None of these are not available in jspInit(). The bold ones also exist as JSP implicit variables.

  • param - Request parameters as strings
  • paramValues - Request parameters as collections of strings
  • header - HTTP request headers as strings
  • headerValues - HTTP request headers as collections of strings
  • initParam - Context-initialization parameters
  • cookie - Cookie values
  • pageContext - The JSP PageContext object for the current page

Scope variables:


param / paramValues

param          // single parameter value
// for a single parameter, e.g. lastname, the following are oddly equivalent
// , even though lastname is not a collection
paramValues // more than one parameter value for a given parameter name
// access paramValues like this:
${paramValues.food[0]} ${paramValues.food[1]}

header / headerValues

header           // single header value
headerValues //  more than one header value for a given header name
// e.g.


Note: it is NOT cookies, but cookie

cookie // map of cookies
// e.g. 
${cookie.userName.value} // much simpler than looping through Cookie[]


initParam // context init parameters (NOT servlet init parameters)
// e.g. 


pageContext (not a map)

6.4 Create and use arithmetic expressions in EL


  • Strings are non-intuitively cast to ints if numbers, or boolean if "true" or "false"
  • nulls do not throw exceptions
  • null objects may display blank, 0 or false
  • Ternary conditions can be used: A ? B : C

empty returns true for: null, empty collection, empty String

Arithmetic (5)

  • null values treated as 0
  • Division by zero may literally result in Infinity
  • none and "" are treated as zero
/ and div
% and mod

Logical (3)

  • null values treated as false
&& and and
|| and or
! and not

Relational (6)

== and eq
!= and ne
< and lt
> and gt
<= and le (don't confuse with lt)
>= and ge

6.4 Identify the need for iteration and selection in the view, and use JSTL tags to address those needs

The first part of the objective is obvious:

  • Iteration is needed for display multiple items in a collection
  • Selection is needed to selectively display data

The second part is covered under 8. Developing JSP pages using custom tags


If you have questions, corrections, information or examples to add, please comment below.

Add a New Comment