Professional Documents
Culture Documents
Struts is a framework of open-source software that can help you build Web
applications quickly and easily. It relies on standard technologies such as
Java™ beans, Java servlets, Java Server Pages (JSP), and XML. Struts
encourage application architectures based on the Model 2 approach, which is
basically the same as the model-view-controller (MVC) design pattern.
Using Struts to create a complex Web application can help make the
application more maintainable. The application is easier to debug, easier to
extend, and easier to understand.
Struts are hosted by the Apache Software Foundation (ASF) as part of its
Jakarta project. For a detailed description of Struts, see the following Web
site:
1
Table 1. Summary of MVC components
Purpose Description
View Display all or a The user interface that displays
portion of the data information about the model to the
user
Controller Handle events that The flow-control mechanism means
affect the model by which the user interacts with the
or view application
In the JSP Model 1 architecture, the JSP page alone processes the incoming
request and replies to the client, as shown in Figure 1.
2
In the JSP Model 2 architecture, the servlet processes the request, creates
any beans or objects used by the JSP file, and forwards the request, as
shown in Figure 2.
3
The Struts implementation of Model 2 uses a specific type of servlet, called
on action servlet, and one or more actions and action mappings to
implement the controller. It also uses a specific type of Java bean, called a
form bean. As illustrated in Figure 3, the Web server at run time contains
both the view and controller components of a Model 2 Web application, while
a third tier (which is usually outside of the Web server) contains the model.
4
Table 3. Struts's contributions to model, view, and controller
Component Contribution
previous user input.
o When user input is returned from a Web browser,
the bean validates and holds that input either for
use by business logic or (if validation failed) for
subsequent redisplay.
5
for the flow of control, and Web-page designers can work
independently of the developers.
• You can more easily prototype your work. You might do as follows, for
example:
1. Create a prototype Web application that accesses several
workstation-based programs.
2. Change the application in response to user feedback.
3. Implement the production-level programs on the same or other
platforms.
• You can more easily migrate legacy programs, because the view is
separate from the model and the control and can be tailored to
platform and user category.
• You can maintain an environment that comprises different technologies
across different locations.
• The MVC design has an organizational structure that better supports
scalability (building bigger applications) and ease of modification and
maintenance (due to the cleaner separation of tasks).