<%@ taglib prefix="c" uri="http://java.sun.com/jstl/ea/core" %> JSTL: EcmaScript EL Support -- Special Objects Example

Special Objects

In the context of JSTL, some special predefined objects are made available.



Request Parameters (params)

Request parameters can be accessed through a Map object called "params". See the Map Access page for information on how to conveniently access Map objects. As request parameters can have multiple values, the map entries are actually arrays, so the index operator needs to be used to access the actual string value of the parameter.

Enter a value for the parameter "test", which will be displayed below using this technique.

Here is the parameter value:

Expression Output
$params['test'][0]
$params.test[0]



Cookies (cookies)

Cookies can be accessed through a Map object called "cookies". See the Map Access page for information on how to conveniently access Map objects.

Here are the cookies:

$cookie.name $cookie.value cookies[cookie.value.name].value


Request Headers (headers)

Request headers can be accessed through a Map object called "headers". See the Map Access page for information on how to conveniently access Map objects.

Accessing specific headers:

Expression Result
$headers.host
$headers['user-agent']

Iteration over the headers:

$header.key $header.value


Webapp Initialization Parameters (initParams)

Init parameters can be accessed through a Map object called "initParams". See the Map Access page for information on how to conveniently access Map objects.

Iteration over the init parameters:

$initParam.key $initParam.value