Struts Controller Components
The controller component in an MVC application has several responsibilities, including receiving input from a client, invoking a business operation, and coordinating the view to return to the client. Of course, the controller may perform many other functions, but these are a few of the primary ones.
For an application built using the JSP Model 2 approach, the controller is implemented by a Java servlet. This servlet is the centralized point of control for the web application. The controller servlet maps user actions into business operations and then helps to select the view to return to the client based on the request and other state information. As a reminder, Figure 3-5 shows the figure used in Chapter 1 to illustrate how this works.

Figure 3-5. The Struts framework uses a servlet as a controller
In the Struts framework, however, the controller responsibilities are
implemented by several different components, one of which is an
instance of the
org.apache.struts.action.ActionServlet
class.
The Struts ActionServlet
The ActionServlet extends the
javax.servlet.http.HttpServlet
class and is responsible for packaging and routing HTTP traffic to
the appropriate handler in the framework. The
ActionServlet
class is not abstract
and therefore can be used as a concrete controller by your
applications. Prior to Version 1.1 of the Struts framework, the
ActionServlet ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access