O'Reilly logo

Java Enterprise in a Nutshell, Third Edition by William Crawford, Jim Farley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Struts Tags

Struts was one of the first frameworks to provide a library of custom JSP tags . The Struts tags provide an amazing array of utilities useful in JSP; also, they provide access to Struts objects so that you don’t have to include Java snippets in your pages. Since the introduction of JSTL, the most common practice is to prefer a JSTL tag when its functionality is similar to an equivalent Struts tag. Struts tags are still very handy for integrating the rendering of pages to Struts data structures such as Actions and ActionForms. In general, JSTL and Struts tags cohabitate quite well, with one exception: internationalization. For internationalization, you are advised to stick to JSTL or to Struts, because their strategies for bundling up the internationalized versions are different.

There are too many Struts tags to describe in this chapter; we will focus here on the tags and tag attributes that are used in the code example. If you have never used a tag library, read the discussion of JSTL in Chapter 4 first.

In the next section, we’ll look at the core tags for HTML rendering, obtaining bean properties, and forwarding requests to Struts Actions. These tags are in the Struts tag libraries named html, bean, and logic. For each library, you must include a directive at the top of each page that references the particular library, associating it with a prefix of your choosing. (The prefix names html, bean, and logic are conventional, but you may change them to avoid namespace collisions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required