Documente Academic
Documente Profesional
Documente Cultură
• Design Pattern
– Designing a reusable software is a difficult task
– A Design pattern helps in reusable software
• MVC [Model-View-Controller]
– Main concern of MVC is to separate the data
(model) and the user interface (view)
– Separation is achieved by introducing an controller
component
– Controller defines as how the user interface
should react to a user input
User
View Controller
Model
Model
Controller
Request
Step 1
Incoming request is directed to Controller
Controller
Model
Step 2
Controller processes request and forms a data Model
Controller
Step 3
Model is passed to View
View
Controller
View
Step 4
View transforms Model into appropriate output format
Controller
View
Response
Step 5
Response is rendered
…
}
• Advantages
– Lightweight design – for small, static application
– Suitable for small applications having very simple page
flow, little need for centralized security control/logging
– Separation of presentation from content
• Limitations
– Navigation Problem – to change name of JSP file have
to change in many location
– Difficult to maintain an application – large java code
being embedded in JSP page
– Not suitable for large and complex applications
Servlet-centric Scenario
ACCPi7.1, AWAJS- Architecting Web Applications using JSF and Struts
27
JSP Model 2
• Advantages
– Easier to build, maintain and extend
– Single point of control (Servlet) for security &
logging
• Limitations
– Increase Design Complexity
Data
Access
User
Interaction
User Interface
Display
ACCPi7.1, AWAJS- Architecting Web Applications using JSF and Struts
30
Module 2
INTRODUCTION TO STRUTS
• Need of a framework
• Struts MVC Architecture
• Components of Struts
Characteristics of
a Framework
• Model component
• View component
• Controller component
They contain static HTML and JSP library tags to Struts have its own JSP tag libraries which help in
generate dynamic HTML page. The JSP contains development of JSP pages. These custom tags
code for user interaction.The static and the libraries provide a means to create HTML forms
dynamic HTML generated page is sent to the whose data will be captured in Form Beans and
browser. Struts provide JSP tag library which Struts View These allow internationalisation of Java application by
display the data stored in Form Beans. There are
allow beans
Form creating
provide
HTMLa forms
channelforfor
capturing
data transfer
data Components having application content placed into central
and also displaying
between the view andthecontrol
data. layers of struts
utility tags which helps to implement conditional
repository called bundles. Thus, the content are not
application. When a Struts application receives an logic, iteration
hard coded in theand many more.
application and is read from the
HTML form it takes the data from the incoming bundle by the application during execution. The
form and populates the corresponding FormBean. advantage of using resource bundles for storing the
The Controller accesses the data using the getter application content is that it can be changed without
method of FormBean. recompiling the application.
Browser
ActionServlet
RequestProcessor
Action
Model View
Layer Layer
JSP
Action Class 1
(View)
Action Servlet
(Controller) Action Class 2 Model
JSP
(View) Action Class 3
• Code Extensibility
– Many Struts values are represented in XML or in property files,
so changes can be made to the file without recompiling the
java code
• Supports for Localization and Internalization
– Using ResourceBundle
• Simple Request Processing Mechanism
– Provides several utilites, such as StructValidatorUtil,
MessageResource class and so on, which simplifies the request
processing mechanism
• Model-View Communication
– Provides a set of taglib tags which allows us to create HTML
forms that directly associates with JavaBean component
• Input Validation
– Provide built-in capability for validation of form values
• Cocoon
– An Apache framework for web development and separates
business logic, presentation logic and component based web
development. The web application is build as a “component
pipeline”.
• WebWork
– Java based Web-application framework. Provides a strong
support to build reusable User Interface templates for form
control, UI themes, internationalization, client and server side
validations and so on.
• Jakarta Velocity
– Another framework similar as Struts has a capacity to do lot
more beyond just creating dynamic web content. Capable of
generating SQL, PostScript, and XML form templates.
• Stxx
– An extension of Struts framework to support XML and
XSL without changing the Struts functionality
• JSF
– Designed to simplifies the process of building GUI’s of
Java Server Applications. Provides standard JSP tags and
API’s which helps in managing complex HTML forms,
event handling activities, and presentation of data.
• Spring
– New framework for J2EE applications. Different from
other frameworks, because it provides a way to manage
business objects. It is comprehensive and modular
ANTLR
Jakarta
Jakarta
Commons
ORO
BeanUtils
Struts
Jakarta
component Jakarta
Commons
Validator
package Commons
Digester .
Jakarta Jakarta
Commons Commons
Logging FileUpload