Tag Libraries Included with Struts

The Struts framework provides a fairly rich set of framework components. It also includes a set of tag libraries that are designed to interact intimately with the rest of the framework. The custom tags provided by the Struts framework are grouped into four distinct libraries:

  • HTML

  • Bean

  • Logic

  • Tiles

There also is a fifth library, called the Nested tag library, that we’ll talk about separately later in this chapter.

Tip

Earlier versions of the Struts framework contained a tag library called Form. It was replaced with the HTML tag library several versions ago, but form tags still sometimes show up in the documentation or example applications.

The tags within a particular library perform similar or related functions. For example, the tags within the HTML tag library are used to render HTML presentation components inside HTML forms. There’s a tag to generate a checkbox, another for a button, and yet another to generate a hyperlink.

Using Tag Libraries with Struts Applications

There’s nothing special about using the Struts tags—they are like any other JSP custom tags. You must include the TLD declarations for each tag library you use in every page in which you need to use them. If you need to use the HTML and Logic tag libraries in a JSP page, for example, insert the following two lines at the top of the JSP page:

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

Once these lines are included ...

Get Programming Jakarta Struts, 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.