Java Reference
In-Depth Information
servlet). The forEach will iterate over those values without you having to code
the explicit next() calls or index your way through an array.
The bottom of the loop is delimited by the closing tag:
</my:forEach>
For more information on these and other tags, check out
http://java.sun.com/products/jsp/jstl
http://jakarta.apache.org/products/jsp/jstl
• The references at the end of this chapter
Beyond the standard library of tags, there are other third-party collections
of tags; you can also create your own libraries, called custom tag libraries . While
a useful and powerful thing to do if you have a large JSP-based application,
such details would expand this topic well beyond its scope. If you're interested
in this topic, please follow up with some of the excellent references at the end
of this chapter.
19.4
U SING JSP WITH B UDGET P RO
We could have taken the BudgetPro example from the previous chapter and
simply translated it all into JSP files. The reason we didn't is that it's not how
you are likely to find JSP used “in the wild.” Since JSP files become servlets, it
is not uncommon to find JSP and servlets mixed together—not arbitrarily, but
in a sensible way. Remember the Model/View/Controller (MVC) pattern from
your readings on object-oriented programming and design patterns? 2 Well, JSP
makes for a reasonable View, and a plain servlet can act as the Controller. The
Model is typically the database behind all this. That's what we've done with
the BudgetPro example.
We've taken the two main chunks of output code—that for the main ac-
count display and the form used for creating subaccounts—and turned those
2. If not, then a) you should do some more reading, and b) the MVC pattern is a “classic” way
to divide the work of a GUI into three distinct parts: Model—the data behind what you are
doing or displaying; View—a particular way to display that data; and Controller—an object
that acts as the “traffic cop” to various inputs and events, sending messages to either the View,
or Model, or both.
Search WWH ::




Custom Search