The jsp:attribute element allows you to define the value of a tag attribute in the body of an XML element instead of in the value of an XML attribute.
For example, the Duke’s Bookstore template page screendefinitions.jsp uses jsp:attribute to use the output of fmt:message to set the value of the value attribute of tt:parameter:
... <tt:screen id="/bookcatalog"> <tt:parameter name="title" direct="true"> <jsp:attribute name="value" > <fmt:message key="TitleBookCatalog"/> </jsp:attribute> </tt:parameter> <tt:parameter name="banner" value="/template/banner.jsp" direct="false"/> <tt:parameter name="body" value="/bookcatalog.jsp" direct="false"/> </tt:screen> ...
jsp:attribute accepts a name attribute and a trim attribute. The name attribute identifies which tag attribute is being specified. The optional trim attribute determines whether or not white space appearing at the beginning and end of the element body should be discarded. By default, the leading and trailing white space is discarded. The white space is trimmed when the JSP page is translated. If a body contains a custom tag that produces leading or trailing white space, that white space is preserved regardless of the value of the trim attribute.
An empty body is equivalent to specifying "" as the value of the attribute.
The body of jsp:attribute is restricted according to the type of attribute being specified:
For simple attributes that accept an EL expression, the body can be any JSP content.
For simple attributes that do not accept an EL expression, the body can contain only static text.
For fragment attributes, the body must not contain any scripting elements (see Chapter 9, Scripting in JSP Pages).