Struts Request Processing Overview
With power comes complexity, unfortunately. Before jumping into the details, here’s a brief summary of the parts of Struts I use for the Project Billboard application.
The Struts servlet delegates the real processing of requests to
classes that extends the Struts Action
class. The
main method in this class is the perform( )
method. For each type of request the application supports, you create
a separate action class and provide the code for processing this
request type in the perform( )
method. Figure 19-3 shows the action classes used by the Project
Billboard application.
The Struts servlet uses parts of the request URI to figure out which
type of request it is, locates the corresponding action class (using
configuration information), and invokes the perform(
)
method. Note that this method doesn’t
render a response; it takes care of business logic only, for
instance, updating a database. The perform( )
method returns a Struts ActionForward
instance,
containing information about the JSP page that should be invoked to
render the response. The page is identified by a logical name
(errorPage
, mainPage
, etc.),
mapped to the real page path in a configuration file. The page flow
can therefore be controlled, at least to some extent, by
reconfiguration instead of code changes.
Get JavaServer Pages, 3rd 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.