Chapter 5. Struts Controller Components

As discussed in Chapter 1, the controller components are responsible for detecting user input, possibly updating the domain model, and selecting the next view for the client. The controller helps to separate the presentation of the model from the model itself. This separation gives you much more freedom to develop a variety of presentations based on a single domain model.

Using a controller provides a centralized point of control where all client requests are initially processed. Centralizing control in this way realizes two requirements of MVC design. First, the controller acts as the mediator/translator between client input and the model, providing common functionality such as security, logging, and other important services on behalf of each client request. Second, because all requests are filtered through the controller, the view is decoupled both from the business logic and from other view components. The view returned to the client is entirely up to the controller. This makes your applications much more flexible.

The Struts framework uses a servlet to process incoming requests. However, it relies on many other components that are part of the controller domain to help carry out its responsibilities. The Struts controller components were mentioned briefly in previous chapters, but it’s time to take an in-depth look at what components have responsibility for the controller functionality in the framework.

The Controller Mechanism

The J2EE Front ...

Get Programming Jakarta Struts, Second 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.