Name

<fmt:message>

Synopsis

The <fmt:message> action adds the localized message for the specified key to the current response buffer (JspWriter) or saves it in a scoped variable. For a parameterized message, the parameter values are specified by nested <fmt:param> actions.

Syntax 1: Without a body

<fmt:message key="messageKey" [bundle="resourceBundle"] 
  [var="var" [scope="page|request|session|application"]] />

Syntax 2: With a body for parameters

<fmt:message key="messageKey" messageKey [bundle="resourceBundle"] 
  [var="var" [scope="page|request|session|application"]]>
  <fmt:param> actions
</fmt:message>

Syntax 3: With a body for the key and parameters

<fmt:message [bundle="resourceBundle"] 
  [var="var" [scope="page|request|session|application"]]>
  messageKey
                       <fmt:param> actions
</fmt:message>

Attributes

Attributename

Java type

Dynamic valueaccepted

Description

key
String

Yes

Message key.

bundle
javax.servlet.jsp.jstl.fmt.LocalizationContext

Yes

Localization context with the resource bundle to use.

var
String

No

The variable name. The type is String.

scope
String

No

The variable scope.

Example

<fmt:message key="simpleMessage" />
  
<fmt:message key="result">
  <fmt:param value="${result.total}" />
  <fmt:param value="${result.percentage}" />
</fmt:message>

Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.