Struts is the premier framework for building
Java-based Web applications. Using the
Model-View-Controller (MVC) design
patterns, Struts solves many of the problems
associated with developing high performance,
business-oriented Web
applications that use Java Servlets and Java
Server Pages.
Strut framework was intended to address
issues that were inherent in using either
Java Server Pages or servlet implementation
of an application. For instance, servlets can
generate HTML pages, but doing so is very
tedious. On the other hand, JSP can work
easily with traditional HTML pages, but JSP
pages have other disadvantages.
JSP are special cases of servlets. In
particular, separating content from the
presentation of that content is difficult
using JSP. So, both JSP and Servelets can
work together to mitigate the disadvantages of each.
Understanding of the Model-View-Controller (MVC) architecture is crucial for
understanding Struts. MVC is based on an older Graphical User Interface (GUI) design
pattern that has been around for some time, with its origins in the Smalltalk World.
Based on MVC the JSP specifications advocated two philosophical approaches for
building applications using JSP technology. These approaches, termed the Model 1
and Model 2 architectures, differ essentially in the location at which the bulk of the
request processing was performed.
In the Model 1 architecture, the request is received and largely processed through
the JSP. If the JSP page requires services from any other application component, suchas a database, then you make the appropriate call from the page, return the data to
the page, and format it for display.
Although the Model 1 architecture should be perfectly suitable for simple
applications, it may not be desirable for complex projects that may lead to an unclear
definition of roles and allocation of responsibilities, causing project-management
headaches.
Model 2 approach takes the best characteristics of the JSP and servlet approaches
and enables these technologies to work together. Here servlet acts as a processing
layer (the controller). The servlet accepts requests and determines how to satisfy
those requests. In that sense, the servlet regulates incoming requests and outgoing
responses. The business logic represents the model in the MVC architecture. |