Tag reference sheet

Tag library reference for the following tag libraries:

bean

Note: Some of the features in this taglib are also available in the JavaServer Pages Standard Tag Library (JSTL). The Struts team encourages the use of the standard tags over the Struts specific tags when possible.

This tag library contains tags useful in accessing beans and their properties, as well as defining new beans (based on these accesses) that are accessible to the remainder of the page via scripting variables and page scope attributes. Convenient mechanisms to create new beans based on the value of request cookies, headers, and parameters are also provided.

Many of the tags in this tag library will throw a JspException at runtime when they are utilized incorrectly (such as when you specify an invalid combination of tag attributes). JSP allows you to declare an "error page" in the <%@ page %> directive. If you wish to process the actual exception that caused the problem, it is passed to the error page as a request attribute under key org.apache.struts.action.EXCEPTION.

This is version 1.3.

  • cookie Define a scripting variable based on the value(s) of the specified request cookie
  • define Define a scripting variable based on the value(s) of the specified bean property
  • header Define a scripting variable based on the value(s) of the specified request header
  • include Load the response from a dynamic application request and make it available as a bean
  • message Render an internationalized message string to the response
  • page Expose a specified item from the page context as a bean
  • parameter Define a scripting variable based on the value(s) of the specified request parameter
  • resource Load a web application resource and make it available as a bean
  • size Define a bean containing the number of elements in a Collection or Map
  • struts Expose a named Struts internal configuration object as a bean
  • write Render the value of the specified bean property to the current JspWriter
Required attributes are marked with a *

<bean:cookie>

Define a scripting variable based on the value(s) of the specified request cookie.

Retrieve the value of the specified request cookie (as a single value or multiple values, depending on the multiple attribute), and define the result as a page scope attribute of type Cookie (if multiple is not specified) or Cookie[] (if multiple is specified).

If no cookie with the specified name can be located, and no default value is specified, a request time exception will be thrown.

Can contain: empty

Attributes

NameDescriptionType
id*

Specifies the name of the scripting variable (and associated page scope attribute) that will be made available with the value of the specified request cookie.

String
multiple

If any arbitrary value for this attribute is specified, causes all matching cookies to be accumulated and stored into a bean of type Cookie[]. If not specified, the first value for the specified cookie will be retrieved as a value of type Cookie.

String
name*

Specifies the name of the request cookie whose value, or values, is to be retrieved.

String
value

The default cookie value to return if no cookie with the specified name was included in this request.

String

<bean:define>

Define a scripting variable based on the value(s) of the specified bean property.

Create a new attribute (in the scope specified by the toScope property, if any), and a corresponding scripting variable, both of which are named by the value of the id attribute. The corresponding value to which this new attribute (and scripting variable) is set are specified via use of exactly one of the following approaches (trying to use more than one will result in a JspException being thrown):

  • Specify a name attribute (plus optional property and scope attributes) - The created attribute and scripting variable will be of the type of the retrieved JavaBean property, unless it is a Java primitive type, in which case it will be wrapped in the appropriate wrapper class (i.e. int is wrapped by java.lang.Integer).
  • Specify a value attribute - The created attribute and scripting variable will be of type java.lang.String, set to the value of this attribute.
  • Specify nested body content - The created attribute and scripting variable will be of type java.lang.String, set to the value of the nested body content.
If a problem occurs while retrieving the specified bean property, a request time exception will be thrown.

The <bean:define> tag differs from <jsp:useBean> in several ways, including:

  • Unconditionally creates (or replaces) a bean under the specified identifier.
  • Can create a bean with the value returned by a property getter of a different bean (including properties referenced with a nested and/or indexed property name).
  • Can create a bean whose contents is a literal string (or the result of a runtime expression) specified by the value attribute.
  • Does not support nested content (such as <jsp:setProperty> tags) that are only executed if a bean was actually created.
USAGE NOTE - There is a restriction in the JSP 1.1 Specification that disallows using the same value for an id attribute more than once in a single JSP page. Therefore, you will not be able to use <bean:define> for the same bean name more than once in a single page.

USAGE NOTE - If you use another tag to create the body content (e.g. bean:write), that tag must return a non-empty String. An empty String equates to an empty body or a null String, and a new scripting variable cannot be defined as null. Your bean must return a non-empty String, or the define tag must be wrapped within a logic tag to test for an empty or null value.

USAGE NOTE - You cannot use bean:define to instantiate a DynaActionForm (type="org.apache.struts.action.DynaActionForm") with the properties specified in the struts-config. The mechanics of creating the dyna-properties is complex and cannot be handled by a no-argument constructor. If you need to create an ActionForm this way, you must use a conventional ActionForm.

See the Bean Developer's Guide section on bean creation for more information about these differences, as well as alternative approaches to introducing beans into a JSP page.

Can contain: JSP

Attributes

NameDescriptionType
id*

Specifies the name of the scripting variable (and associated page scope attribute) that will be made available with the value of the specified property.

String
name

Specifies the attribute name of the bean whose property is accessed to define a new page scope attribute (if property is also specified) or the attribute name of the bean that is duplicated with the new reference created by this tag (if property is not also specified). This attribute is required unless you specify a value attribute or nested body content.

String
property

Specifies the name of the property to be accessed on the bean specified by name. This value may be a simple, indexed, or nested property reference expression. If not specified, the bean identified by name is given a new reference identified by id.

String
scope

Specifies the variable scope searched to retrieve the bean specified by name. If not specified, the default rules applied by PageContext.findAttribute() are applied.

String
toScope

Specifies the variable scope into which the newly defined bean will be created. If not specified, the bean will be created in page scope.

String
type

Specifies the fully qualified class name of the value to be exposed as the id attribute.

String
value

The java.lang.String value to which the exposed bean should be set. This attribute is required unless you specify the name attribute or nested body content.

String

<bean:header>

Define a scripting variable based on the value(s) of the specified request header.

Retrieve the value of the specified request header (as a single value or multiple values, depending on the multiple attribute), and define the result as a page scope attribute of type String (if multiple is not specified) or String[] (if multiple is specified).

If no header with the specified name can be located, and no default value is specified, a request time exception will be thrown.

Can contain: empty

Attributes

NameDescriptionType
id*

Specifies the name of the scripting variable (and associated page scope attribute) that will be made available with the value of the specified request header.

String
multiple

If any arbitrary value for this attribute is specified, causes a call to HttpServletRequest.getHeaders() and a definition of the result as a bean of type String[]. Otherwise, HttpServletRequest.getHeader() will be called, and a definition of the result as a bean of type String will be performed.

String
name*

Specifies the name of the request header whose value, or values, is to be retrieved.

String
value

The default header value to return if no header with the specified name was included in this request.

String

<bean:include>

Load the response from a dynamic application request and make it available as a bean.

Perform an internal dispatch to the specified application component (or external URL) and make the response data from that request available as a bean of type String. This tag has a function similar to that of the standard <jsp:include> tag, except that the response data is stored in a page scope attribute instead of being written to the output stream. If the current request is part of a session, the generated request for the include will also include the session identifier (and thus be part of the same session).

The URL used to access the specified application component is calculated based on which of the following attributes you specify (you must specify exactly one of them):

  • forward - Use the value of this attribute as the name of a global ActionForward to be looked up, and use the module-relative or context-relative URI found there.
  • href - Use the value of this attribute unchanged (since this might link to a resource external to the application, the session identifier is not included.
  • page - Use the value of this attribute as an module-relative URI to the desired resource.
Can contain: empty

Attributes

NameDescriptionType
anchor

Optional anchor tag ("#xxx") to be added to the generated hyperlink. Specify this value without any "#" character.

String
forward

Logical name of a global ActionForward that contains the actual content-relative URI of the resource to be included.

String
href

Absolute URL (including the appropriate protocol prefix such as "http:") of the resource to be included. Because this URL could be external to the current web application, the session identifier will not be included in the request.

String
id*

Specifies the name of the scripting variable (and associated page scope attribute) that will be made available with the value of the specified web application resource.

String
page

Module-relative URI (starting with a '/') of the web application resource to be included.

String
transaction

Set to true if you want the current transaction control token included in the generated URL for this include.

boolean

<bean:message>

Render an internationalized message string to the response.

Retrieves an internationalized message for the specified locale, using the specified message key, and write it to the output stream. Up to five parametric replacements (such as "{0}") may be specified.

The message key may be specified directly, using the key attribute, or indirectly, using the name and property attributes to obtain it from a bean.

JSTL: The equivalent JSTL tag is <fmt:message>. For example, <fmt:message key="my.msg.key"> <fmt:param value="replacement text"/> </fmt:message>

Can contain: empty

Attributes

NameDescriptionType
arg0

First parametric replacement value, if any.

String
arg1

Second parametric replacement value, if any.

String
arg2

Third parametric replacement value, if any.

String
arg3

Fourth parametric replacement value, if any.

String
arg4

Fifth parametric replacement value, if any.

String
bundle

The name of the application scope bean under which the MessageResources object containing our messages is stored.

String
key

The message key of the requested message, which must have a corresponding value in the message resources. If not specified, the key is obtained from the name and property attributes.

String
locale

The name of the session scope bean under which our currently selected Locale object is stored.

String
name

Specifies the attribute name of the bean whose property is accessed to retrieve the value specified by property (if specified). If property is not specified, the value of this bean itself will be used as the message resource key.

String
property

Specifies the name of the property to be accessed on the bean specified by name. This value may be a simple, indexed, or nested property reference expression. If not specified, the value of the bean identified by name will itself be used as the message resource key.

String
scope

Specifies the variable scope searched to retrieve the bean specified by name. If not specified, the default rules applied by PageContext.findAttribute() are applied.

String

<bean:page>

Expose a specified item from the page context as a bean.

Retrieve the value of the specified item from the page context for this page, and define it as a scripting variable, and a page scope attribute accessible to the remainder of the current page.

If a problem occurs while retrieving the specified configuration object, a request time exception will be thrown.

Can contain: empty

Attributes

NameDescriptionType
id*

Specifies the name of the scripting variable (and associated page scope attribute) that will be made available with the value of the specified page context property.

String
property*

Name of the property from our page context to be retrieved and exposed. Must be one of application, config, request, response, or session.

String

<bean:parameter>

Define a scripting variable based on the value(s) of the specified request parameter.

Retrieve the value of the specified request parameter (as a single value or multiple values, depending on the multiple attribute), and define the result as a page scope attribute of type String (if multiple is not specified) or String[] (if multiple is specified).

If no request parameter with the specified name can be located, and no default value is specified, a request time exception will be thrown.

Can contain: empty

Attributes

NameDescriptionType
id*

Specifies the name of the scripting variable (and associated page scope attribute) that will be made available with the value of the specified request parameter.

String
multiple

If any arbitrary value for this attribute is specified, causes a call to ServletRequest.getParameterValues() and a definition of the result as a bean of type String[]. Otherwise, ServletRequest.getParameter() will be called, and a definition of the result as a bean of type String will be performed.

String
name*

Specifies the name of the request parameter whose value, or values, is to be retrieved.

String
value

The default parameter value to return if no parameter with the specified name was included in this request.

String

<bean:resource>

Load a web application resource and make it available as a bean.

Retrieve the value of the specified web application resource, and make it available as either a InputStream or a String, depending on the value of the input attribute.

If a problem occurs while retrieving the specified resource, a request time exception will be thrown.

Can contain: empty

Attributes

NameDescriptionType
id*

Specifies the name of the scripting variable (and associated page scope attribute) that will be made available with the value of the specified web application resource.

String
input

If any arbitrary value for this attribute is specified, the resource will be made available as an InputStream. If this attribute is not specified, the resource will be made available as a String.

String
name*

Module-relative name (starting with a '/') of the web application resource to be loaded and made available.

String

<bean:size>

Define a bean containing the number of elements in a Collection or Map.

Given a reference to an array, Collection or Map, creates a new bean, of type java.lang.Integer, whose value is the number of elements in that collection. You can specify the collection to be counted in any one of the following ways:

  • As a runtime expression specified as the value of the collection attribute.
  • As a JSP bean specified by the name attribute.
  • As the property, specified by the property attribute, of the JSP bean specified by the name attribute.
Can contain: empty

Attributes

NameDescriptionType
collection

A runtime expression that evaluates to an array, a Collection, or a Map.

String
id*

The name of a page scope JSP bean, of type java.lang.Integer, that will be created to contain the size of the underlying collection being counted.

String
name

The name of the JSP bean (optionally constrained to the scope specified by the scope attribute) that contains the collection to be counted (if property is not specified), or whose property getter is called to return the collection to be counted (if property is specified.

String
property

The name of the property, of the bean specified by the name attribute, whose getter method will return the collection to be counted.

String
scope

The bean scope within which to search for the JSP bean specified by the name attribute. If not specified, the available scopes are searched in ascending sequence.

String

<bean:struts>

Expose a named Struts internal configuration object as a bean.

Retrieve the value of the specified Struts internal configuration object, and define it as a scripting variable and as a page scope attribute accessible to the remainder of the current page. You must specify exactly one of the formBean, forward, and mapping attributes to select the configuration object to be exposed.

If a problem occurs while retrieving the specified configuration object, a request time exception will be thrown.

Can contain: empty

Attributes

NameDescriptionType
formBean

Specifies the name of the Struts ActionFormBean definition object to be exposed.

String
forward

Specifies the name of the global Struts ActionForward definition object to be exposed.

String
id*

Specifies the name of the scripting variable (and associated page scope attribute) that will be made available with the value of the specified Struts internal configuration object.

String
mapping

Specifies the matching path of the Struts ActionMapping definition object to be exposed.

String

<bean:write>

Render the value of the specified bean property to the current JspWriter.

Retrieve the value of the specified bean property, and render it to the current JspWriter as a String by the ways:

  • If format attribute exists then value will be formatted on base of format string from format attribute and default system locale.
  • If in resources exists format string for value data type (view format attribute description) then value will be formatted on base of format string from resources. Resources bundle and target locale can be specified with bundle and locale attributes. If nothing specified then default resource bundle and current user locale will be used.
  • If there is a PropertyEditor configured for the property value's class, the getAsText() method will be called.
  • Otherwise, the usual toString() conversions will be applied.
When a format string is provided, numeric values are formatted using the java.text.DecimalFormat class; if the format string came from a resource, the applyLocalisedPattern() method is used, and applyPattern() is used otherwise. Dates are formatted using the SimpleDateFormat class. For details of the specific format patterns, please see the Javadocs for those classes.

If a problem occurs while retrieving the specified bean property, a request time exception will be thrown.

Can contain: empty

Attributes

NameDescriptionType
bundle

The name of the application scope bean under which the MessageResources object containing our messages is stored.

String
filter

If this attribute is set to true, the rendered property value will be filtered for characters that are sensitive in HTML, and any such characters will be replaced by their entity equivalents.

boolean
format

Specifies the format string to use to convert bean or property value to the String. If nothing specified, then default format string for value data type will be searched in message resources by according key.

String
formatKey

Specifies the key to search format string in application resources.

String
ignore

If this attribute is set to true, and the bean specified by the name and scope attributes does not exist, simply return without writing anything. If this attribute is set to false, a runtime exception to be thrown, consistent with the other tags in this tag library.

boolean
locale

The name of the session scope bean under which our currently selected Locale object is stored.

String
name*

Specifies the attribute name of the bean whose property is accessed to retrieve the value specified by property (if specified). If property is not specified, the value of this bean itself will be rendered.

String
property

Specifies the name of the property to be accessed on the bean specified by name. This value may be a simple, indexed, or nested property reference expression. If not specified, the bean identified by name will itself be rendered. If the specified property returns null, no output will be rendered.

String
scope

Specifies the variable scope searched to retrieve the bean specified by name. If not specified, the default rules applied by PageContext.findAttribute() are applied.

String

html

This taglib contains tags used to create struts input forms, as well as other tags generally useful in the creation of HTML-based user interfaces.

Many of the tags in this tag library will throw a JspException at runtime when they are utilized incorrectly (such as when you specify an invalid combination of tag attributes). JSP allows you to declare an "error page" in the <%@ page %> directive. If you wish to process the actual exception that caused the problem, it is passed to the error page as a request attribute under key org.apache.struts.action.EXCEPTION.

This is version 1.3.

  • base Render an HTML &lt;base&gt; Element Renders an HTML &lt;base&gt; element with an href attribute pointing to the absolute location of the enclosing JSP page
  • button Render A Button Input Field Renders an HTML &lt;input&gt; element of type button, populated from the specified value or the content of this tag body
  • cancel Render a Cancel Button Renders an HTML &lt;input&gt; element of type submit
  • checkbox Render A Checkbox Input Field Renders an HTML &lt;input&gt; element of type checkbox, populated from the specified value or the specified property of the bean associated with our current form
  • errors Conditionally display a set of accumulated error messages
  • file Render A File Select Input Field Renders an HTML &lt;input&gt; element of type file, defaulting to the specified value or the specified property of the bean associated with our current form
  • form Define An Input Form Renders an HTML &lt;form&gt; element whose contents are described by the body content of this tag
  • frame Render an HTML frame element Renders an HTML &lt;frame&gt; element with processing for the src attribute that is identical to that performed by the &lt;html:link&gt; tag for the href attribute
  • hidden Render A Hidden Field Renders an HTML &lt;input&gt; element of type hidden, populated from the specified value or the specified property of the bean associated with our current form
  • html Render an HTML &lt;html&gt; Element Renders an HTML &lt;html&gt; element with language attributes extracted from the user's current Locale object, if there is one
  • image Render an input tag of type "image" Renders an HTML &lt;input&gt; tag of type "image"
  • img Render an HTML img tag Renders an HTML &lt;img&gt; element with the image at the specified URL
  • javascript Render JavaScript validation based on the validation rules loaded by the ValidatorPlugIn
  • link Render an HTML anchor or hyperlink Renders an HTML &lt;a&gt; element as an anchor definition (if "linkName" is specified) or as a hyperlink to the specified URL
  • messages Conditionally display a set of accumulated messages
  • multibox Render A Checkbox Input Field Renders an HTML &lt;input&gt; element of type checkbox, whose "checked" status is initialized based on whether the specified value matches one of the elements of the underlying property's array of current values
  • option Render A Select Option Render an HTML &lt;option&gt; element, representing one of the choices for an enclosing &lt;select&gt; element
  • options Render a Collection of Select Options Renders a set of HTML &lt;option&gt; elements, representing possible choices for a &lt;select&gt; element
  • optionsCollection Render a Collection of Select Options Renders a set of HTML &lt;option&gt; elements, representing possible choices for a &lt;select&gt; element
  • param Adds a parameter to the following tags: &lt;html:frame&gt; &lt;html:link&gt; &lt;html:rewrite&gt; Since: Struts 1
  • password Render A Password Input Field Renders an HTML &lt;input&gt; element of type password, populated from the specified value or the specified property of the bean associated with our current form
  • radio Render A Radio Button Input Field Renders an HTML &lt;input&gt; element of type radio, populated from the specified property of the bean associated with our current form
  • reset Render A Reset Button Input Field Renders an HTML &lt;input&gt; element of type reset
  • rewrite Render an URI Renders a request URI based on exactly the same rules as the link tag does, but without creating the &lt;a&gt; hyperlink
  • select Render A Select Element Renders an HTML &lt;select&gt; element, associated with a bean property specified by our attributes
  • submit Render A Submit Button Renders an HTML &lt;input&gt; element of type submit
  • text Render An Input Field of Type text Render an input field of type text
  • textarea Render A Textarea Render a textarea element
  • xhtml Render HTML tags as XHTML Using this tag in a page tells all other html taglib tags to render themselves as XHTML 1
Required attributes are marked with a *

<html:base>

Render an HTML <base> Element

Renders an HTML <base> element with an href attribute pointing to the absolute location of the enclosing JSP page. This tag is valid only when nested inside an HTML <head> element.

This tag is useful because it allows you to use relative URL references in the page that are calculated based on the URL of the page itself, rather than the URL to which the most recent submit took place (which is where the browser would normally resolve relative references against).

Can contain: empty

Attributes

NameDescriptionType
ref

The reference from which the base uri will created. Possible values are:

  • page - The base uri will be the jsp page location. (default)
  • site - The base uri will be the application context path.
Since: Struts 1.3
String
server The server name to use instead of request.getServerName(). String
target

The window target for this base reference.

String

<html:button>

Render A Button Input Field

Renders an HTML <input> element of type button, populated from the specified value or the content of this tag body. This tag is only valid when nested inside a form tag body.

If a graphical button is needed (a button with an image), then the image tag is more appropriate.

Can contain:

Attributes

NameDescriptionType
accesskey

The keyboard character used to move focus immediately to this element.

String
alt

The alternate text for this element.

String
altKey

The message resources key of the alternate text for this element.

String
bundle

The servlet context attributes key for the MessageResources instance to use. If not specified, defaults to the application resources configured for our action servlet.

Since: Struts 1.2.5
String
dir

The direction for weak/neutral text for this element.

Since: Struts 1.3.6
String
disabled

Set to true if this input field should be disabled.

boolean
indexed

Valid only inside of logic:iterate tag. If true then name of the html tag will be rendered as "propertyName[34]". Number in brackets will be generated for every iteration and taken from ancestor logic:iterate tag.

boolean
lang

The language code for this element.

Since: Struts 1.3.6
String
onblur JavaScript event handler executed when this element loses input focus. String
onchange JavaScript event handler executed when this element loses input focus and its value has changed. String
onclick JavaScript event handler executed when this element receives a mouse click. String
ondblclick JavaScript event handler executed when this element receives a mouse double click. String
onfocus JavaScript event handler executed when this element receives input focus. String
onkeydown JavaScript event handler executed when this element has focus and a key is depressed. String
onkeypress JavaScript event handler executed when this element has focus and a key is depressed and released. String
onkeyup JavaScript event handler executed when this element has focus and a key is released. String
onmousedown JavaScript event handler executed when this element is under the mouse pointer and a mouse button is depressed. String
onmousemove JavaScript event handler executed when this element is under the mouse pointer and the pointer is moved. String
onmouseout JavaScript event handler executed when this element was under the mouse pointer but the pointer was moved outside the element. String
onmouseover JavaScript event handler executed when this element was not under the mouse pointer but the pointer is moved inside the element. String
onmouseup JavaScript event handler executed when this element is under the mouse pointer and a mouse button is released. String
property* Name of the request parameter that will be included with this submission, set to the specified value. String
style CSS styles to be applied to this HTML element. String
styleClass CSS stylesheet class to be applied to this HTML element (renders a "class" attribute). String
styleId Identifier to be assigned to this HTML element (renders an "id" attribute). String
tabindex The tab order (ascending positive integers) for this element. String
title

The advisory title for this element.

String
titleKey

The message resources key for the advisory title for this element.

String
value Value of the label to be placed on this button. This value will also be submitted as the value of the specified request parameter. [Body of this tag (if any), or "Click"] String

<html:cancel>

Render a Cancel Button

Renders an HTML <input> element of type submit. This tag is only valid when nested inside a form tag body. Pressing of this submit button causes the action servlet to bypass calling the associated form bean validate() method. The action is called normally.

Can contain:

Attributes

NameDescriptionType
accesskey The keyboard character used to move focus immediately to this element. String
alt

The alternate text for this element.

String
altKey

The message resources key of the alternate text for this element.

String
bundle The servlet context attributes key for the MessageResources instance to use. If not specified, defaults to the application resources configured for our action servlet. Since: Struts 1.2.5 String
dir

The direction for weak/neutral text for this element.

Since: Struts 1.3.6
String
disabled Set to true if this input field should be disabled. boolean
lang

The language code for this element.

Since: Struts 1.3.6
String
onblur JavaScript event handler executed when this element loses input focus. String
onchange JavaScript event handler executed when this element loses input focus and its value has changed. String
onclick JavaScript event handler executed when this element receives a mouse click. String
ondblclick JavaScript event handler executed when this element receives a mouse double click. String
onfocus JavaScript event handler executed when this element receives input focus. String
onkeydown JavaScript event handler executed when this element has focus and a key is depressed. String
onkeypress JavaScript event handler executed when this element has focus and a key is depressed and released. String
onkeyup JavaScript event handler executed when this element has focus and a key is released. String
onmousedown JavaScript event handler executed when this element is under the mouse pointer and a mouse button is depressed. String
onmousemove JavaScript event handler executed when this element is under the mouse pointer and the pointer is moved. String
onmouseout JavaScript event handler executed when this element was under the mouse pointer but the pointer was moved outside the element. String
onmouseover JavaScript event handler executed when this element was not under the mouse pointer but the pointer is moved inside the element. String
onmouseup JavaScript event handler executed when this element is under the mouse pointer and a mouse button is released. String
property Name of the request parameter that will be included with this submission, set to the specified value. WARNING - If you set this attribute to a value other than the default, this will NOT be recognized as the cancel key by the Struts controller servlet or the Action.isCancelled() method. You will need to do your own cancel detection. String
style CSS styles to be applied to this HTML element. String
styleClass CSS stylesheet class to be applied to this HTML element (renders a "class" attribute). String
styleId Identifier to be assigned to this HTML element (renders an "id" attribute). String
tabindex The tab order (ascending positive integers) for this element. String
title

The advisory title for this element.

String
titleKey

The message resources key for the advisory title for this element.

String
value Value of the label to be placed on this button. This value will also be submitted as the value of the specified request parameter. [Body of this tag (if any), or "Cancel"] String

<html:checkbox>

Render A Checkbox Input Field

Renders an HTML <input> element of type checkbox, populated from the specified value or the specified property of the bean associated with our current form. This tag is only valid when nested inside a form tag body.

NOTE: The underlying property value associated with this field should be of type boolean, and any value you specify should correspond to one of the Strings that indicate a true value ("true", "yes", or "on"). If you wish to utilize a set of related String values, consider using the multibox tag.

WARNING: In order to correctly recognize unchecked checkboxes, the ActionForm bean associated with this form must include a statement setting the corresponding boolean property to false in the reset() method.

Can contain:

Attributes

NameDescriptionType
accesskey The keyboard character used to move focus immediately to this element. String
alt

The alternate text for this element.

String
altKey

The message resources key of the alternate text for this element.

String
bundle The servlet context attributes key for the MessageResources instance to use. If not specified, defaults to the application resources configured for our action servlet. Since: Struts 1.2.5 String
dir

The direction for weak/neutral text for this element.

Since: Struts 1.3.6
String
disabled Set to true if this input field should be disabled. boolean
errorKey

Name of the bean (in any scope) under which our error messages have been stored. If not present, the name specified by the Globals.ERROR_KEY constant string will be used.

N.B. This is used in conjunction with the errorStyle, errorStyleClass and errorStyleId attributes and should be set to the same value as the name attribute on the <html:errors/> tag.

Since: Struts 1.2.5
String
errorStyle

CSS styles to be applied to this HTML element if an error exists for it.

N.B. If present, this overrides the style attribute in the event of an error.

Since: Struts 1.2.5
String
errorStyleClass

CSS stylesheet class to be applied to this HTML element if an error exists for it (renders a "class" attribute).

N.B. If present, this overrides the styleClass attribute in the event of an error.

Since: Struts 1.2.5
String
errorStyleId

Identifier to be assigned to this HTML element if an error exists for it (renders an "id" attribute).

N.B. If present, this overrides the styleId attribute in the event of an error.

Since: Struts 1.2.5
String
indexed Valid only inside of logic:iterate tag. If true then name of the html tag will be rendered as "id[34].propertyName". Number in brackets will be generated for every iteration and taken from ancestor logic:iterate tag. boolean
lang

The language code for this element.

Since: Struts 1.3.6
String
name The attribute name of the bean whose properties are consulted when rendering the current value of this input field. If not specified, the bean associated with the form tag we are nested within is utilized. String
onblur JavaScript event handler executed when this element loses input focus. String
onchange JavaScript event handler executed when this element loses input focus and its value has changed. String
onclick JavaScript event handler executed when this element receives a mouse click. String
ondblclick JavaScript event handler executed when this element receives a mouse double click. String
onfocus JavaScript event handler executed when this element receives input focus. String
onkeydown JavaScript event handler executed when this element has focus and a key is depressed. String
onkeypress JavaScript event handler executed when this element has focus and a key is depressed and released. String
onkeyup JavaScript event handler executed when this element has focus and a key is released. String
onmousedown JavaScript event handler executed when this element is under the mouse pointer and a mouse button is depressed. String
onmousemove JavaScript event handler executed when this element is under the mouse pointer and the pointer is moved. String
onmouseout JavaScript event handler executed when this element was under the mouse pointer but the pointer was moved outside the element. String
onmouseover JavaScript event handler executed when this element was not under the mouse pointer but the pointer is moved inside the element. String
onmouseup JavaScript event handler executed when this element is under the mouse pointer and a mouse button is released. String
property* Name of the request parameter that will be included with this submission, set to the specified value. String
style

CSS styles to be applied to this HTML element.

N.B. If present, the errorStyle overrides this attribute in the event of an error for the element.

String
styleClass

CSS stylesheet class to be applied to this HTML element (renders a "class" attribute).

N.B. If present, the errorStyleClass overrides this attribute in the event of an error for the element.

String
styleId

Identifier to be assigned to this HTML element (renders an "id" attribute).

N.B. If present, the errorStyleId overrides this attribute in the event of an error for the element.

String
tabindex The tab order (ascending positive integers) for this element. String
title

The advisory title for this element.

String
titleKey

The message resources key for the advisory title for this element.

String
value The value to be transmitted if this checkbox is checked when the form is submitted. If not specified, the value "on" will be returned. String

<html:errors>

Conditionally display a set of accumulated error messages.

Displays a set of error messages prepared by a business logic component and stored as an ActionMessages object, an ActionErrors object, a String, or a String array in any scope. If such a bean is not found, nothing will be rendered.

In order to use this tag successfully, you must have defined an application scope MessageResources bean under the default attribute name, with optional definitions of message keys specified in the following attributes:

  • header - Text that will be rendered before the error messages list. Typically, this message text will end with <ul> to start the error messages list (default "errors.header").
  • footer - Text that will be rendered after the error messages list. Typically, this message text will begin with </ul> to end the error messages list (default "errors.footer").
  • prefix - Text that will be rendered before each individual error in the list (default "errors.prefix").
  • suffix - Text that will be rendered after each individual error in the list (default "errors.suffix").
See the messages tag for an alternative to this tag that does not rely on HTML in your MessageResources.

Can contain: empty

Attributes

NameDescriptionType
bundle The servlet context attribute key for the MessageResources instance to use. If not specified, defaults to the application resources configured for our action servlet. String
footer This value is an optional message resource key that will be printed after the iteration of error messages has finished. Defaults to "errors.footer" if not specified. Since: Struts 1.2.5 String
header This value is an optional message resource key that will be printed before the iteration of error messages begins. Defaults to "errors.header" if not specified. Since: Struts 1.2.5 String
locale The session attribute key for the Locale used to select messages to be displayed. If not specified, defaults to the Struts standard value. String
name Name of the bean (in any scope) under which our error messages have been stored. If not present, the name specified by the Globals.ERROR_KEY constant string will be used. String
prefix This value is an optional message resource key that will be printed before an error message. Defaults to "errors.prefix" if not specified. Since: Struts 1.2.5 String
property Name of the property for which error messages should be displayed. If not specified, all error messages (regardless of property) are displayed. String
suffix This value is an optional message resource key that will be printed after an error message. Defaults to "errors.suffix" if not specified. Since: Struts 1.2.5 String

<html:file>

Render A File Select Input Field

Renders an HTML <input> element of type file, defaulting to the specified value or the specified property of the bean associated with our current form. This tag is only valid when nested inside a form tag body.

As with the corresponding HTML <input> element, the enclosing form element must specify "POST" for the method attribute, and "multipart/form-data" for the enctype attribute. For example:

    <html:form method="POST" enctype="multipart/form-data">
        <html:file property="theFile" />
    </html:form>

WARNING: In order to correctly recognize uploaded files, the ActionForm bean associated with this form must include a statement setting the corresponding org.apache.struts.upload.FormFile property to null in the reset() method.

Can contain:

Attributes

NameDescriptionType
accept Comma-delimited set of content types that the server you submit to knows how to process. This list can be used by the client browser to limit the set of file options that is made available for selection. If not specified, no content type list will be sent. String
accesskey The keyboard character used to move focus immediately to this element. String
alt

The alternate text for this element.

String
altKey

The message resources key of the alternate text for this element.

String
bundle The servlet context attributes key for the MessageResources instance to use. If not specified, defaults to the application resources configured for our action servlet. Since: Struts 1.2.5 String
dir

The direction for weak/neutral text for this element.

Since: Struts 1.3.6
String
disabled Set to true if this input field should be disabled. boolean
errorKey

Name of the bean (in any scope) under which our error messages have been stored. If not present, the name specified by the Globals.ERROR_KEY constant string will be used.

N.B. This is used in conjunction with the errorStyle, errorStyleClass and errorStyleId attributes and should be set to the same value as the name attribute on the <html:errors/> tag.

Since: Struts 1.2.5
String
errorStyle

CSS styles to be applied to this HTML element if an error exists for it.

N.B. If present, this overrides the style attribute in the event of an error.

Since: Struts 1.2.5
String
errorStyleClass

CSS stylesheet class to be applied to this HTML element if an error exists for it (renders a "class" attribute).

N.B. If present, this overrides the styleClass attribute in the event of an error.

Since: Struts 1.2.5
String
errorStyleId

Identifier to be assigned to this HTML element if an error exists for it (renders an "id" attribute).

N.B. If present, this overrides the styleId attribute in the event of an error.

Since: Struts 1.2.5
String
indexed Valid only inside of logic:iterate tag. If true then name of the html tag will be rendered as "id[34].propertyName". Number in brackets will be generated for every iteration and taken from ancestor logic:iterate tag. boolean
lang

The language code for this element.

Since: Struts 1.3.6
String
maxlength Maximum number of input characters to accept. This is ignored by most browsers. [No limit] String
name The attribute name of the bean whose properties are consulted when rendering the current value of this input field. If not specified, the bean associated with the form tag we are nested within is utilized. String
onblur JavaScript event handler executed when this element loses input focus. String
onchange JavaScript event handler executed when this element loses input focus and its value has changed. String
onclick JavaScript event handler executed when this element receives a mouse click. String
ondblclick JavaScript event handler executed when this element receives a mouse double click. String
onfocus JavaScript event handler executed when this element receives input focus. String
onkeydown JavaScript event handler executed when this element has focus and a key is depressed. String
onkeypress JavaScript event handler executed when this element has focus and a key is depressed and released. String
onkeyup JavaScript event handler executed when this element has focus and a key is released. String
onmousedown JavaScript event handler executed when this element is under the mouse pointer and a mouse button is depressed. String
onmousemove JavaScript event handler executed when this element is under the mouse pointer and the pointer is moved. String
onmouseout JavaScript event handler executed when this element was under the mouse pointer but the pointer was moved outside the element. String
onmouseover JavaScript event handler executed when this element was not under the mouse pointer but the pointer is moved inside the element. String
onmouseup JavaScript event handler executed when this element is under the mouse pointer and a mouse button is released. String
property* Name of the request parameter that will be included with this submission, set to the specified value. String
size Size of the file selection box to be displayed. String
style

CSS styles to be applied to this HTML element.

N.B. If present, the errorStyle overrides this attribute in the event of an error for the element.

String
styleClass

CSS stylesheet class to be applied to this HTML element (renders a "class" attribute).

N.B. If present, the errorStyleClass overrides this attribute in the event of an error for the element.

String
styleId

Identifier to be assigned to this HTML element (renders an "id" attribute).

N.B. If present, the errorStyleId overrides this attribute in the event of an error for the element.

String
tabindex The tab order (ascending positive integers) for this element. String
title

The advisory title for this element.

String
titleKey

The message resources key for the advisory title for this element.

String
value

NOTE: When setting this to some value, whether intentional or as the result (for example) of validation errors forcing the user back to the original jsp, this value is ignored by most browsers (for security reasons). This means that your users will have to re-select any previously selected files when submitting the form. Opera web browser will prompt the user so they have a chance to abort the submit.

Value to which this field should be initialized. [Use the corresponding bean property value or body content (if any) if property is not specified]
String

<html:form>

Define An Input Form

Renders an HTML <form> element whose contents are described by the body content of this tag. The form implicitly interacts with the specified request scope or session scope bean to populate the input fields with the current property values from the bean.

The form bean is located, and created if necessary, based on the form bean specification for the associated ActionMapping.

Can contain: JSP

Attributes

NameDescriptionType
acceptCharset The list of character encodings for input data that the server should accept. Since: Struts 1.2.2 String
action

The URL to which this form will be submitted. This value is also used to select the ActionMapping we are assumed to be processing, from which we can identify the appropriate form bean and scope. If a value is not provided, the original URI (servletPath) for the request is used.

If you are using extension mapping for selecting the controller servlet, this value should be equal to the path attribute of the corresponding <action> element, optionally followed by the correct extension suffix.

If you are using path mapping to select the controller servlet, this value should be exactly equal to the path attribute of the corresponding <action> element.

String
dir

The direction for weak/neutral text for this element.

Since: Struts 1.3.6
String
disabled Set to true if the Form's input fields should be disabled. Since: Struts 1.2.7 boolean
enctype The content encoding to be used to submit this form, if the method is POST. This must be set to "multipart/form-data" if you are using the file tag to enable file upload. If not specified, the browser default (normally "application/x-www-form-urlencoded") is used. String
focus The field name (among the fields on this form) to which initial focus will be assigned with a JavaScript function. If not specified, no special JavaScript for this purpose will be rendered. String
focusIndex If the focus field is a field array, such as a radio button group, you can specify the index in the array to receive focus. Since: Struts 1.1 String
lang

The language code for this element.

Since: Struts 1.3.6
String
method The HTTP method that will be used to submit this request (GET, POST). [POST] String
onreset JavaScript event handler executed if the form is reset. String
onsubmit JavaScript event handler executed if the form is submitted. String
readonly Set to true if the Form's input fields should be read only. Since: Struts 1.2.7 boolean
scriptLanguage The form's focus <script> element will not contain a language attribute when this is set to false. The default is true but this property is ignored in XHMTL mode. Since: Struts 1.2 boolean
style CSS styles to be applied to this HTML element. String
styleClass CSS stylesheet class to be applied to this HTML element (renders a "class" attribute). String
styleId Identifier to be assigned to this HTML element (renders an "id" attribute). String
target Window target to which this form is submitted, such as for use in framed presentations. String

<html:frame>

Render an HTML frame element

Renders an HTML <frame> element with processing for the src attribute that is identical to that performed by the <html:link> tag for the href attribute. URL rewriting will be applied automatically, to maintain session state in the absence of cookies.

The base URL for this frame is calculated based on which of the following attributes you specify (you must specify exactly one of them):

  • forward - Use the value of this attribute as the name of a global ActionForward to be looked up, and use the module-relative or context-relative URI found there.
  • href - Use the value of this attribute unchanged.
  • page - Use the value of this attribute as a module-relative URI, and generate a server-relative URI by including the context path and application prefix.
  • action - Use the value of this attribute as the logical name of a global Action that contains the actual content-relative URI of the destination of this transfer.
Normally, the hyperlink you specify with one of the attributes described in the previous paragraph will be left unchanged (other than URL rewriting if necessary). However, there are two ways you can append one or more dynamically defined query parameters to the hyperlink -- specify a single parameter with the paramId attribute (and its associated attributes to select the value), or specify the name (and optional property) attributes to select a java.util.Map bean that contains one or more parameter ids and corresponding values.

To specify a single parameter, use the paramId attribute to define the name of the request parameter to be submitted. To specify the corresponding value, use one of the following approaches:

  • Specify only the paramName attribute - The named JSP bean (optionally scoped by the value of the paramScope attribute) must identify a value that can be converted to a String.
  • Specify both the paramName and paramProperty attributes - The specified property getter method will be called on the JSP bean identified by the paramName (and optional paramScope) attributes, in order to select a value that can be converted to a String.
If you prefer to specify a java.util.Map that contains all of the request parameters to be added to the hyperlink, use one of the following techniques:
  • Specify only the name attribute - The named JSP bean (optionally scoped by the value of the scope attribute) must identify a java.util.Map containing the parameters.
  • Specify both name and property attributes - The specified property getter method will be called on the bean identified by the name (and optional scope) attributes, in order to return the java.util.Map containing the parameters.
As the Map is processed, the keys are assumed to be the names of query parameters to be appended to the hyperlink. The value associated with each key must be either a String or a String array representing the parameter value(s), or an object whose toString() method will be called. If a String array is specified, more than one value for the same query parameter name will be created.

Additionally, you can request that the current transaction control token, if any, be included in the generated hyperlink by setting the transaction attribute to true. You can also request that an anchor ("#xxx") be added to the end of the URL that is created by any of the above mechanisms, by using the anchor attribute.

Can contain: JSP

Attributes

NameDescriptionType
action

Logical name of a global Action that contains the actual content-relative URI of the destination of this transfer. This hyperlink may be dynamically modified by the inclusion of query parameters, as described in the tag description. You must specify exactly one of the action attribute, the forward attribute, the href attribute, or the page attribute.

Additionally, you can specify a module prefix for linking to other modules.

String
anchor

Optional anchor tag ("#xxx") to be added to the generated hyperlink. Specify this value without any "#" character.

String
bundle The servlet context attributes key for the MessageResources instance to use. If not specified, defaults to the application resources configured for our action servlet. Since: Struts 1.2.5 String
forward

Logical name of a global ActionForward that contains the actual content-relative URI of the destination of this transfer. This hyperlink may be dynamically modified by the inclusion of query parameters, as described in the tag description. You must specify exactly one of the action attribute, the forward attribute, the href attribute, or the page attribute.

String
frameName

Value for the name attribute of the rendered <frame> element.

String
frameborder

Should a frame border be generated around this frame (1) or not (0)?

String
href

The URL to which this hyperlink will transfer control if activated. This hyperlink may be dynamically modified by the inclusion of query parameters, as described in the tag description. You must specify exactly one of the action attribute, the forward attribute, the href attribute, or the page attribute.

String
longdesc

URI of a long description of the frame. This description should supplement the short description provided by the title attribute, and may be particularly useful for non-visual user agents.

String
marginheight

The amount of space (in pixels) to be left between the frame's contents and its top and bottom margins.

String
marginwidth

The amount of space (in pixels) to be left between the frame's contents and its left and right margins.

String
module

Prefix name of a Module that contains the action mapping for the Action that is specified by the action attribute. You must specify an action attribute for this to have an effect.

Note: Use "" to map to the default module.

String
name

The name of a JSP bean that contains a Map representing the query parameters (if property is not specified), or a JSP bean whose property getter is called to return a Map (if property is specified).

String
noresize

Should users be disallowed from resizing the frame? (true, false).

boolean
page

The module-relative path (beginning with a "/" character) to which this hyperlink will transfer control if activated. This hyperlink may be dynamically modified by the inclusion of query parameters, as described in the tag description. You must specify exactly one of the action attribute, the forward attribute, the href attribute, or the page attribute.

String
paramId

The name of the request parameter that will be dynamically added to the generated hyperlink. The corresponding value is defined by the paramName and (optional) paramProperty attributes, optionally scoped by the paramScope attribute

String
paramName

The name of a JSP bean that is a String containing the value for the request parameter named by paramId (if paramProperty is not specified), or a JSP bean whose property getter is called to return a String (if paramProperty is specified). The JSP bean is constrained to the bean scope specified by the paramScope property, if it is specified.

String
paramProperty

The name of a property of the bean specified by the paramName attribute, whose return value must be a String containing the value of the request parameter (named by the paramId attribute) that will be dynamically added to this hyperlink.

String
paramScope

The scope within which to search for the bean specified by the paramName attribute. If not specified, all scopes are searched.

String
property

The name of a property of the bean specified by the name attribute, whose return value must be a java.util.Map containing the query parameters to be added to the hyperlink. You must specify the name attribute if you specify this attribute.

String
scope

The scope within which to search for the bean specified by the name attribute. If not specified, all scopes are searched.

String
scrolling

Should scroll bars be created unconditionally (yes), never (no), or only when needed (auto)?

String
style

CSS styles to be applied to this element.

String
styleClass CSS stylesheet class to be applied to this HTML element (renders a "class" attribute). String
styleId Identifier to be assigned to this HTML element (renders an "id" attribute). String
title

The advisory title for this element.

String
titleKey

The message resources key for the advisory title for this element.

String
transaction

If set to true, any current transaction control token will be included in the generated hyperlink, so that it will pass an isTokenValid() test in the receiving Action.

boolean

<html:hidden>

Render A Hidden Field

Renders an HTML <input> element of type hidden, populated from the specified value or the specified property of the bean associated with our current form. This tag is only valid when nested inside a form tag body.

Can contain: empty

Attributes

NameDescriptionType
accesskey The keyboard character used to move focus immediately to this element. String
alt

The alternate text for this element.

String
altKey

The message resources key of the alternate text for this element.

String
bundle The servlet context attributes key for the MessageResources instance to use. If not specified, defaults to the application resources configured for our action servlet. Since: Struts 1.2.5 String
dir

The direction for weak/neutral text for this element.

Since: Struts 1.3.6
String
disabled Set to true if this input field should be disabled. boolean
indexed Valid only inside of logic:iterate tag. If true then name of the html tag will be rendered as "id[34].propertyName". Number in brackets will be generated for every iteration and taken from ancestor logic:iterate tag. boolean
lang

The language code for this element.

Since: Struts 1.3.6
String
name The attribute name of the bean whose properties are consulted when rendering the current value of this input field. If not specified, the bean associated with the form tag we are nested within is utilized. String
onblur JavaScript event handler executed when this element loses input focus. String
onchange JavaScript event handler executed when this element loses input focus and its value has changed. String
onclick JavaScript event handler executed when this element receives a mouse click. String
ondblclick JavaScript event handler executed when this element receives a mouse double click. String
onfocus JavaScript event handler executed when this element receives input focus. String
onkeydown JavaScript event handler executed when this element has focus and a key is depressed. String
onkeypress JavaScript event handler executed when this element has focus and a key is depressed and released. String
onkeyup JavaScript event handler executed when this element has focus and a key is released. String
onmousedown JavaScript event handler executed when this element is under the mouse pointer and a mouse button is depressed. String
onmousemove JavaScript event handler executed when this element is under the mouse pointer and the pointer is moved. String
onmouseout JavaScript event handler executed when this element was under the mouse pointer but the pointer was moved outside the element. String
onmouseover JavaScript event handler executed when this element was not under the mouse pointer but the pointer is moved inside the element. String
onmouseup JavaScript event handler executed when this element is under the mouse pointer and a mouse button is released. String
property* Name of this input field, and the name of the corresponding bean property if value is not specified. The corresponding bean property (if any) must be of type String. String
style CSS styles to be applied to this HTML element. String
styleClass CSS stylesheet class to be applied to this HTML element (renders a "class" attribute). String
styleId Identifier to be assigned to this HTML element (renders an "id" attribute). String
title

The advisory title for this element.

String
titleKey

The message resources key for the advisory title for this element.

String
value Value to which this field should be initialized. [Use the corresponding bean property value] String
write Should the value of this field also be rendered to the response page to make it visible, in addition to creating an HTML type="hidden" element? By default, only the hidden element is created. boolean

<html:html>

Render an HTML <html> Element

Renders an HTML <html> element with language attributes extracted from the user's current Locale object, if there is one.

Can contain: JSP

Attributes

NameDescriptionType
lang Renders a lang attribute with the locale stored in the user's session. If not found in the session, the language from the Accept-Language HTTP header is used. If still not found, the default language for the server is used. Since: Struts 1.2 boolean
xhtml

Set to true in order to render xml:lang and xmlns attributes on the generated html element. This also causes all other html tags to render as XHTML 1.0 (the <html:xhtml/> tag has a similar purpose).

Since: Struts 1.1
boolean

<html:image>

Render an input tag of type "image"

Renders an HTML <input> tag of type "image". The base URL for this image is calculated directly based on the value specified in the src or page attributes, or indirectly by looking up a message resource string based on the srcKey or pageKey attributes. You must specify exactly one of these attributes.

If you would like to obtain the coordinates of the mouse click that submitted this request, see the information below on the property attribute.

This tag is only valid when nested inside a form tag body.

Can contain:

Attributes

NameDescriptionType
accesskey

The keyboard character used to move focus immediately to this element.

String
align

The alignment option for this image.

String
alt

The alternate text for this image.

String
altKey

The message resources key of the alternate text for this image.

String
border

The width (in pixels) of the border around this image.

String
bundle

The servlet context attribute key for the MessageResources instance to use. If not specified, defaults to the application resources configured for our action servlet.

String
dir

The direction for weak/neutral text for this element.

Since: Struts 1.3.6
String
disabled Set to true if this input field should be disabled. boolean
indexed Valid only inside of logic:iterate tag. If true then name of the html tag will be rendered as "propertyName[34]". Number in brackets will be generated for every iteration and taken from ancestor logic:iterate tag. boolean
lang

The language code for this element.

Since: Struts 1.3.6
String
locale

The session attribute key for the Locale used to select internationalized message