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 Action
s and ActionForm
s. 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 ...
Get Java Enterprise in a Nutshell, Third 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.