JSTL 1.0 Referenz

JSTL Expression Language Definition (Server Pages Tag Library)
Implicit ObjectContains
pageScopeVariables which have the scope page.
requestScopeVariables which have the scope request.
sessionScopeVariables which have the scope session.
applicationScopeVariables which have the scope of the application.
pageContextJSP PageContext object
cookieCookie values
paramRequest parameters as strings.
headerHTTP request headers as strings.
headerValuesHTTP request headers as a collection of strings
initParamContext initialization parameters
JSTL Operators
Property access:Dot operator (.) can be used to retrieve a named property. To access numbered or named properties use the bracket operator ([] ).
Example: ${user.name}, ${row[0]} or ${order.items.price}
Use the empty operator to determine whether a collection or string is empty or null . Example: <c:if test="${empty pageScope.users}">
Comparison operators:== / eq, != / ne, < / lt, > / gt, <= / le, >= / ge
Logical operators:&& / and, | | / or, ! / not
Arithmetic operators:+, -, *, /, % / mod
Legend
All tags are case sensitive. A pair of single quotes is equivalent to a pair of double quotes. Spaces are not allowed between an equals sign and an attribute value.
value = default value
attribute = using a body, the content is associated with this attribute
plain text = required
italics = user-defined
{ } = required choice
| = or
[ ] = optional
... = list of items
ex.= exported
sc. = scoped
*   The "dyn" (dynamic) column title presents the rtexprvalue element defined in a TLD.
    It captures the dynamic behaviour of an attribute for both library versions.
**   page|request|session|application
***  default|short|medium|long|full
ActionDescriptionSyntaxAttributes
Core Tag Library - General Purpose Actions namedyn*typedescription
<c:out>Evaluates an expression and outputs the result to the current JspWriter object.<c:out
  value="value"
  [escapeXml="{true |false}"]
[ default="defaultValue" ] />
valuetrueObjectExpression to be evaluated.
escapeXmltrueboolean Determines whether <,>,&,'," in the result should be converted to their corresponding character entity codes.
defaulttrueObjectDefault value if the resulting value is null.
<c:set>Sets the value of a scoped variable or a property of a target object.<c:set
value="value"  var="varName"
  [scope="{**}"] />

or

<c:set
  value="value"
  target="target"
  property="propertyName" />
valuetrueObjectExpression to be evaluated.
varfalseStringScoped variable to hold the value specified in the action.
scopefalseStringScope for var.
targettrueObjectJavaBeans object with setter property, or to a java.util.Map object.
propertytrueStringName of the property to be set in the target object.
<c:remove>Removes a scoped variable.<c:remove
  var="varName"
 [scope="{**}"] />
varfalseStringName of the scoped variable to be removed.
scopefalseStringScope for var.
<c:catch>Catches a java.lang.Throwable thrown by any of its nested actions.<c:catch
  [var="varName"]>

nested actions

</c:catch>
varfalseStringVariable to expose information about error.
Core Tag Library - Conditional Actions namedyn*typedescription
<c:if>Evaluates its body content if the expression is true.<c:if
  test="testCondition"
  [var="varName"]
  [scope="{**}"]>

body content

</c:if>
testtruebooleanTest condition that determines whether or not the body content should be processed.
varfalseStringName of the exported scoped variable for the resulting test condition value.
scopefalseStringScope for var.
Constraints: If scope is specified, var must also be specified.
<c:choose>
<c:when>
<c:otherwise>
Provides the context for mutually exclusive conditional execution.<c:choose>
  <c:when
    test="testCondition1">
body content
  </c:when>

  <c:when
    test="testCondition2">
body content
  </c:when>
  ...
  <c:otherwise>
conditional block
  </c:otherwise>
</c:choose>
testtruebooleanTest condition - determines whether or not the body content should be processed.
Constraints: The body of <c:choose> can only contain 1 or more <c:when> actions (must all appear before <c:otherwise>) and 0 or 1 <c:otherwise> action (must be the last action)
Core Tag Library - Iterator Actions namedyn*typedescription
<c:forEach> Repeats its nested body content over a collection of objects, or repeats it a fixed number of times. <c:forEach
  [var="varName"]
  items="collection"
  [varStatus="varStatusName"]
  [begin="begin"]
  [end="end"]
  [step="step"]>

body content

</c:forEach>
varfalseString Name of the exported scoped variable for the current item. Its type depends on the object of the underlying collection.
itemstrue(see descr.)Collection of items to iterate over. Types can contain all supported types.
varStatusfalseStringName of the exported scoped variable for the status of the iteration.
begin / endtrueintIteration begins / ends at the specified index (items) or at the specified value.
steptrueintIteration will only process every step items.
Constraints: If items is not specified, begin and end must be specified.
<c:forTokens>Iterates over tokens, separated by the supplied delimiters.<c:forTokens
  items="stringOfTokens"
  delims="delimiters"
  [var="varName"]
  [varStatus="varStatusName"]
  [begin="begin"]
  [end="end"]
  [step="step"]>

body content

</c:forToken>
varfalseStringName of the exported scoped variable for the current item of the iteration.
itemstrueStringString of tokens to iterate over.
delimstrueStringThe set of delimiters (the characters that separate the tokens in the string).
varStatusfalseStringName of the exported scoped variable for the status of the iteration.
begin / endtrueintIteration begins / ends at the token located at the specified index.
steptrueintIteration will only process every step tokens.
Core Tag Library - URL Related Actions namedyn*typedescription
<c:redirect>Sends an HTTP redirect to the client.<c:redirect
  url="value"
  [context="context"] />

optional <c:param> subtags within the body
urltrueStringThe URL of the resource to redirect to.
contexttrueStringContext name when specifying a relative URL that belongs to a foreign context.
<c:param>Adds request parameters to a URL.<c:param
  name="name"
  value="value" />
nametrueStringName of the query string parameter.
valuetrueStringValue of the parameter.
<c:import>Imports the content of a URL-based resource.<c:import
  url="url"
  [context="context"]
  [var="varName"]
  [scope="{**}"]
  [varReader="varReaderName"]
  [charEncoding="charEncoding"] />

optional <c:param> subtags within the body
urltrueStringThe URL of the resource to import.
contexttrueStringContext name when specifying a relative URL that belongs to a foreign context.
varfalseStringName of the exported scoped variable for the resource's content.
scopefalseStringScope for var.
charEncodingtrueStringCharacter encoding of the content at the input resource.
varReaderfalseStringName of the exported scoped variable for the resource's content. (Type: Reader)
Constraints: If varReader is specified, var and scope must not be specified.
<c:url>Builds a URL with the proper rewriting rules applied.<c:url
  value="value"
  [context="context"]
  [var="varName"]
  [scope="{**}"] />

optional <c:param> subtags within the body
valuetrueStringURL to be processed.
contexttrueStringName of the ex. sc. variable for the resource's content.
varfalseStringName of the ex. sc. variable for the processed url.
scopefalseStringScope for var.
SQL Actions namedyn*typedescription
<sql:query>Queries a database.<sql:query
  sql="sqlQuery"
  var="varName"
  [scope="{**}"]
  [dataSource="dataSource"]
  [maxRows="maxRows"]
  [startrow="startrow"] />

optional <sql:param> actions within the body
sqltrueStringSQL query statement.
dataSourcetrue String,
javax.sql. DataSource
JNDI Data source
maxRowstrueintThe maximum number of rows to be included in the query result.
startrowtrueintThe returned Result object includes the rows starting at the specified index.
varfalseStringName of the exported scoped variable for the query result.
scopefalseStringScope for var.
<sql:update> Executes an SQL INSERT, UPDATE, or DELETE statement. (and SQL statements that return nothing) <sql:update
  sql="sqlUpdate"
  [dataSource="dataSource"]
  [var="varName"]
  [scope="{**}"] />

optional <sql:param> actions within the body
sqltrueStringSQL update statement.
dataSourcetrue String,
javax.sql. DataSource
JNDI Data source
varfalseStringName of the exported scoped variable for the result of the database update.(Integer)
scopefalseStringScope for var.
<sql:transaction> Establishes a transaction context for <sql:query> and
  <sql:update> subtags.
<sql:transaction
  [dataSource="dataSource"]
  [isolation="isolationLevel"]>

    <sql:query> and
    <sql:update> statements

</sql:transaction>
dataSourcetrue String,
javax.sql. DataSource
JNDI Data source
isolationtrueStringMax contain read_committed | read_uncommitted | repeatable_read | serializable.
Constraints: Any nested <sql:query> and <sql:update> actions must not specify a dataSource attribute.
<sql:setdataSource> Exports a data source either as a scoped variable or as the data source configuration variable (javax.servlet.jsp.jstl.sql.dataSource). <sql:setdataSource
  {dataSource="dataSource" |
  [url="jdbcUrl"]
  [driver="driverClassName"]
  [user="userName"]
  [password="password"]}
  [var="varName"]
  [scope="{**}"] />
dataSourcetrueString, javax.sql.DataSourceJNDI Data source
drivertrueStringClass name of the JDBC driver.
urltrueStringJDBC database URL.
usertrueStringJDBC database user
passwordtrueStringJDBC user password
varfalseStringName of the ex. sc. variable for the data source specified. Type: String / DataSource.
scopefalseStringScope for var.
<sql:param>Sets the values of parameter markers ("?") in a SQL statement.<sql:param
value="value" />
valuetrueObjectParameter value.
<sql:dateParam> Like <sql:param> for values of type java.util.Date. Subtag of <sql:query> and <sql:update>.<sql:dateParam
  value="value"
  type="[timestamp|time|date]" />
valuetruejava.util.DateParameter value for DATE, TIME, or TIMESTAMP column.
typetrueStringOne of "date", "time" or "timestamp".
XML Tag Library - XML Core Actions namedyn*typedescription
<x:out> Evaluates an XPath expression and outputs the result to the current JspWriter object. <x:out
  select="XPathExpression"
  [escapeXml="{true|false}"] />
selectfalseStringXPath expression.
escapeXmltrueboolean Deterrmines whether <,>,&,'," in the result should be converted to their corresponding character entity codes.
<x:parse>Parses an XML document.<x:parse
xml="XMLDocument"
  {var="var"
  [scope={**}]
  |varDom="var"
  [scopeDom="scope"]}
  [systemId="systemId"]
  [filter="filter"] />
xmltrueString, ReaderSource XML document to be parsed.
systemIdtrueStringThe system identifier (URI) for parsing the XML document.
filtertrueorg.xml.sax. XMLFilterFilter to be applied to the source document.
vartrueStringName of the exported scoped variable for the parsed XML document.
scopefalseStringScope for var.
varDomfalseStringSee var. The type of the sc. variable is org.w3c.dom.Document.
scopeDomfalseStringScope for varDom.
<x:set>Evaluates an XPath expression and stores the result into a scoped variable.<x:set
  select="XPathExpression"
  var="varName"
  [scope="{**}"] />
selectfalseStringXPath expression to be evaluated.
varfalseStringName of the ex. sc. variable to hold the value specified in the action.
scopefalseStringScope for var.
XML Tag Library - XML Flow Control Actions namedyn*typedescription
<x:if> Evaluates the XPath expression specified in the select attribute and renders its body content if the expression evaluates to true. <x:if
  select="XPathExpression"
  [var="varName"]
  [scope="{**}"]>

body content

</x:if>>
selectfalseStringThe test condition that tells whether or not the body content should be processed.
varfalseStringName of the ex. sc. variable for the resulting value of the condition. (Boolean)
scopefalseStringScope for var.
Constraints: If scope is specified, var must also be specified.
<x:choose>
<x:when>
<x:otherwise>
Provides the context for mutually exclusive conditional execution.<x:choose>
  <x:when
  select="XPathExpr">
body content
  </x:when>
  <x:otherwise>conditional block</x:otherwise>
</x:choose>
selectfalseStringTest condition that determines whether or not the body content should be processed.
Constraints: The body of <x:choose> can only contain: 1 or more <x:when> actions (must all appear before <c:otherwise>) 0 or 1 <x:otherwise> action (must be the last action)
<x:forEach> Evaluates the given XPath expression and repeats its nested body content over the result. <x:forEach
  [var="varName"]
  select="XPathExpression">
body content
</x:forEach>
varfalseStringName of the exported scoped variable for the current item of the iteration.
selectfalseStringXPath expression to be evaluated.
XML Tag Library - XML transform Actions namedyn*typedescription
<x:transform>Applies an XSLT stylesheet transformation to an XML document.<x:transform
xml="XMLDocument"
  xslt="XSLTStylesheet"
  [xmlSystemId="XMLSystemId"]
  [xsltSystemId="XSLTSystemId"]
  [{var="varName"
  [scope="{**}"]
  |result="resultObject"}]/>

optional <x:param> subtags within the body
xmltrueString, Reader, javax.xml. transform.Source

Source XML document to be transformed.

Type also: org.w3c.dom.Document, or object exported by <x:parse>, <x:set>.

xslttruesee above (xml)transformation stylesheet as a String, Reader,or Source object.
xmlSystemIdtrueStringThe system identifier (URI) for parsing the XML document.
xsltSystemIdtrueStringThe system identifier (URI) for parsing the XSLT stylesheet.
varfalseStringName of the ex. sc. variable for the transformed XML document.(org.w3c.dom.Document)
scopefalseStringScope for var.
resulttruejavax.xml. transform.ResultObject that captures or processes the transformation result.
<x:param>Set transformation parameters. Nested action of <x:transform>.<x:param
  name="name"
value="value" />
nametrueStringName of the transformation parameter.
valuetrueObjectValue of the parameter.
I18n-capable formatting Tag Library - I18n Actions namedyn*typedescription
<fmt:setLocale> Stores the specified locale in the javax.servlet.jsp.jstl.fmt.locale configuration variable. <fmt:setLocale
  value="locale"
  [variant="variant"]
  [scope="{**}"] />
valuetrue String,
java.util.Locale
A String value is interpreted as the printable representation of a locale. Language and country codes must be separated by hyphen ('-') or underscore ('_').
varianttrueStringVendor- or browser-specific variant.
scopefalseStringScope of the locale configuration variable.
<fmt:bundle>Creates an i18n localization context to be used by its body content.<fmt:bundle
  basename="basename"
  [prefix="prefix"]>
body content
</fmt:bundle>
basenametrueStringResource bundle base name. (fully-qualified)
prefixtrueString Prefix to be prepended to the value of the message key of any nested <fmt:message> action.
<fmt:setBundle> Creates an i18n localization context and stores it in the scoped variable or the localizationContext. <fmt:setBundle
  basename="basename"
  [var="varName"]
  [scope="{**}"] />
basenametrueStringResource bundle base name. (fully-qualified)
varfalseStringName of the exported scoped variable which stores the i18n localization context.
scopefalseStringScope of var or the localization context configuration variable.
<fmt:message>Looks up a localized message in a resource bundle.<fmt:message
  key="messageKey"
  [bundle="resourceBundle"]
  [var="varName"]
  [scope="{**}"] />

optional key and/or

optional <fmt:param> within the body
keytrueStringMessage key to be looked up.
bundletrueLocalization ContextLocalization context in whose resource bundle the message key is looked up.
varfalseStringName of the exported scoped variable which stores the localized message.
scopefalseStringScope for var.
Constraints: If scope is specified, var must also be specified.
<fmt:param>Supplies a single parameter within a <fmt:message> action.<fmt:param
value="messageParameter" />
valuetrueObjectArgument used for parametric replacement.
<fmt:requestEncoding>Sets the request's char. encoding.<fmt:requestEncoding
  [value="charsetName"] />
valuetrueStringName of character encoding to be applied when decoding request parameters.
I18n-capable formatting Tag Library - Formatting Actions namedyn*typedescription
<fmt:timeZone> Specifies the time zone in which time information is to be formatted or parsed in its body content. <fmt:timeZone
  value="timeZone">
body content
</fmt:timeZone>
valuetrue String,
java. util.TimeZone
The time zone. A String value is interpreted as a time zone ID.
<fmt:setTimeZone> Stores the specified time zone in a scoped variable or the time zone configuration variable. <fmt:setTimeZone
  value="timeZone"
  [var="varName"]
  [scope="{**}"] />
valuetrue String,
java. util.TimeZone
The time zone. A String value is interpreted as a time zone ID.
varfalseStringName of the exported scoped variable which stores the time zone of type java.util.TimeZone.
scopefalseStringScope of var or the time zone configuration variable.
<fmt:formatNumber> Formats a numeric value in a locale-sensitive or customized manner as a number, currency, or percentage. <fmt:formatNumber
value="numericValue"
  [type="{number|currency|percent}"]
[pattern="customPattern"]
  [currencyCode="currencyCode"]
  [currencySymbol="currencySymbol"]
  [groupingUsed="{true|false}"]
  [maxIntegerDigits="maxIntegerDigits"]
  [minIntegerDigits="minIntegerDigits"]
  [maxFractionDigits="maxFractionDigits"]
  [minFractionDigits="minFractionDigits"]
  [var="varName"]
  [scope="{**}"] />
valuetrueString, NumberNumeric value to be formatted.
typetrueStringSpecifies whether the value is to be formatted as number, currency, or percentage.
patterntrueStringCustom formatting pattern.
currencyCodetrueStringISO 4217 currency code. Applied only when formatting currencies; ignored otherwise.
currencySymboltrueStringCurrency symbol. Applied only when formatting currencies; ignored otherwise.
groupingUsedtruebooleanSpecifies whether the formatted output will contain any grouping separators.
maxIntegerDigitstrueintMax. number of digits in the integer portion.
minIntegerDigitstrueintMin. number of digits in the integer portion.
maxFractionDigitstrueintMax. number of digits in the fractional portion.
minFractionDigitstrueintMin. number of digits in the fractional portion.
varfalseStringName of the exported scoped variable.
scopefalseStringScope of var.
<fmt:parseNumber> Parses the string representation of numbers, currencies, and percentages that were formatted in a locale-sensitive or customized manner. <fmt:parseNumber
  value="numericValue"
  [type="{number|currency|percent}"]
  [pattern="customPattern"]
  [parseLocale="parseLocale"]
  [integerOnly="{true|false}"]
  [var="varName"]
  [scope="{**}"] />
valuetrueStringString to be parsed.
typetrueString Specifies whether the value attribute should be parsed as a number, currency, or percentage.
patterntrueStringCustom formatting pattern.
parseLocaletrue String,
java.util.Locale
Locale whose default formatting pattern is to be used.
integerOnlytruebooleanSpecifies whether just the integer portion of the given value should be parsed.
varfalseStringName of the exported scoped variable which stores the parsed result (Number).
scopefalseStringScope of var.
Constraints: If scope is specified, var must also be specified.
<fmt:formatdate> Allows the formatting of dates and times in a locale-sensitive or customized manner. <fmt:formatdate
value="date"
  [type="{time|date|both}"]
  [dateStyle="{***}"]
  [timeStyle="{***}"]
  [pattern="customPattern"]
  [timeZone="timeZone"]
  [var="varName"]
  [scope="{**}"] />
valuetruejava.util.DateDate and/or time to be formatted.
typetrueStringSpecifies whether the time, the date, or both are to be formatted.
dateStyletrueStringPredefined formatting style for dates.
timeStyletrueStringPredefined formatting style for times.
patterntrueStringCustom formatting style for dates and times.
timeZonetrue String,
java. util.TimeZone
Time zone in which to represent the formatted time.
varfalseStringName of the exported scoped variable which stores the formatted result as a String.
scopefalseStringScope of var.
<fmt:parseDate> Parses the string representation of dates and times that were formatted in a locale-sensitive or customized manner. <fmt:parseDate
value="dateString"
  [type="{time|date|both}"]
  [dateStyle="{***}"]
  [timeStyle="{***}"]
  [pattern="customPattern"]
  [timeZone="timeZone"]
  [parseLocale="parseLocale"]
  [var="varName"]
  [scope="{**}"] />
valuetrueStringDate string to be parsed.
typetrueStringSpecifies whether the value contains a time,date,or both.
dateStyletrueStringPredefined formatting style for dates.
timeStyletrueStringPredefined formatting style for times.
patterntrueStringCustom formatting pattern for parsing the date string.
timeZonetrue String,
java. util.TimeZone
Time zone in which to interpret any time information.
parseLocaletrue String,
java.util.Locale
Locale whose default formatting pattern is to be used.
varfalseString Name of the ex. sc. variable in which the parsing result (of type java.util.Date) is stored.
scopefalseStringScope of var.
Constraints: If scope is specified, var must also be specified.
Zum Geschaeftsbreich Competence Center
Schulung
Erlernen Sie den Umgang mit Servlets, JSTL und JSF in den Schulungen Servlets und JavaServer Pages JSP und JavaServer Faces.