session 02 struts framework presentation v1.0
TRANSCRIPT
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
1/24
2007, Cognizant Technology Solutions. All Rights Reserved.The information contained herein is subject to change without notice.
C3: Protected
Struts Framework
Targeted at: Entry Level Trainees
Session 02: Understanding Struts Framework
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
2/24
22
About the Author
Created By: Santhosh Perumal (126073)
Baskar Senguttuvan (136303)
Credential
Information:
Baskar - PMP, SEI Architect
Santhosh - SCJP, SCWCD, SCBCD Certified Professional
Version andDate:
STRUTS/PPT/0508/1.0
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
3/24
Questions
Contacts
Reference
TryitOut
HandsonExercise
CodingStandards
TestYourUnderstanding
Tools
AWelcomeBreak
Icons Used
3
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
4/24
44
Struts Framework Session 02:Overview
Introduction:
The struts open source framework was created to
make it easier for developers to build Web
applications based on the Java Servlet and Java
Server Pages (JSP) technologies. Like a building, a Web application must have a solid
foundation from which the rest of the structure can
grow. The struts framework provides developers with
a unified infrastructure upon which Internet
applications can be based.
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
5/24
55
Struts Framework Session 02:Overview (Contd.)
The Struts framework was created by Craig R.
McClanahan and donated to the Apache Software
Foundation (ASF) in 2000. The struts framework is
one of many well-known and successful Apache
Jakarta projects. Others includes Ant, log4j, and
Tomcat.
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
6/2466
Struts Framework Session 02:Objective
Introduction:
After completing this session, you will be able to:
Describe MVC architecture
Explain Struts Core packages
Explain Struts implementation of MVC
Describe the overview of Struts Framework
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
7/2477
MVC Architecture
In the Model View Controller (Model 2) architecture, the
client request is first intercepted by a servlet, commonly
referred to as a controller servlet.
This servlet handles the initial processing of the request
and determines which JSP page to display next.
Client never sends a request directly to a JSP page in
the MVC architecture. This allows the servlet to perform
front-end processing, including authentication and
authorization, centralized logging.
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
8/2488
MVC Architecture (Contd.)
Once request processing gets completed, the servlet
directs the request to the appropriate JSP page. This
approach is illustrated in following figure:
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
9/2499
MVC Architecture (Contd.)
All enterprise data and the business logic to process the
data can be represented in the MODEL.
The VIEW can access the data through the model anddecide on how to present them to the client. The VIEW
must ensure that the presentation changes as and when
the MODEL changes.
The CONTROLLER can interact with the view and
convert the client actions into actions that are
understood and performed by the MODEL. The
CONTROLLER also decides on the next view to be
presented depending on the last client action and
results of the corresponding MODEL actions.
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
10/241010
MVC Architecture (Contd.)
Following diagram displays MVC Architecture
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
11/241111
MVC Architecture (Contd.)
Advantages of MVC architecture:
MVC architecture is suitable for a highly interactive system
that requires extensibility, maintainability, and multiple user
views.
MVC decouples presentation, user interaction, and system
model.
Presenting multiple views for multiple data sets is made easybecause of the decoupling. This also makes it much easier to
enable support for new types of clients.
Code duplication is minimized by using this architecture.
By separating the presentation from model and overallapplication flow, this architecture enables division of
developer responsibilities and thereby, produces faster time
to market.
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
12/2412
What is a Framework?
A framework is a set of classes and interfaces that
operates to solve a specific type of software problem. A
framework has the following characteristics:
A framework comprises multiple classes or components,
each of which may provide an abstraction of some
particular concept.
The framework defines how these abstractions work
together to solve a problem.
Framework components are reusable.
A framework organizes patterns at a higher level.
A good framework should provide generic behavior that
can be used by different types of applications.
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
13/2413
Struts Core Packages
The struts framework is divided into 8 core packages. Figure
shows the top-level packages and their dependencies within
the framework.
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
14/241414
Struts Core Packages (Contd.)
Packagename
Description
action
Contains the controller classes, the ActionForm,ActionMessages, and several other required
framework components.
actions
Contains the "out-of-box" Action classes, such as
DispatchAction, that can be used or extended byyour application.
config
Includes the configuration classes that are in-memory representations of the Struts configuration
file.
taglibContains the tag handler classes for the Struts taglibraries.
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
15/241515
Struts Core Packages (Contd.)
Packagename
Description
tiles Contains the classes used by the Tiles framework.
upload
Includes classes used for uploading and
downloading files from the local filesystem, using
a browser.
utilContains general-purpose utility classes used by
the entire framework.
validator
Contains the Struts-specific extension classes used
by Struts when deploying the validator. Theactual Validator classes and interfaces are in the
commons package, separate from Struts.
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
16/241616
Struts Implementation of MVC
View layer Controller layer Model layer
Struts-
html.tld
Struts-
bean.tld
Struts-
logic.tld
ActionForwards
ActionForm classes
ActionMappings
ActionServlet
Action classes
ActionErrors
MessageResources
GenericDataSource
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
17/2417
Struts Overview
Following graphic explains the struts overview
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
18/2418
Struts Workflow
1. A request comes in with a .doc extension, the container
maps it to the ActionServlet.
2. The ActionServlet acts like a front end controller anddispatches control to a RequestProcessor.
3. The RequestProcessor finds an action tag with a path
attribute that matches the incoming request.4. Then the RequestProcessor looks for a form-bean tag
that has a name attribute that matched the action tags
name attribute.
5. RequestProcessor instantiates a FormBean of the of
based on the type attribute.
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
19/24
19
Struts Workflow (Contd.)
6. RequestProcessor calls populates the FormBeans fields
from the incoming request, then calls its reset method,
then its validate method.7. RequestProcessor instantiates an action based on the
action tags type attribute.
8. RequestProcessor calls the action's execute method,
which returns an ActionForward.
9. The RequestProcessor finds a matching
ActionForward first within the nested forward tags,
then from within the global-forwards tag.
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
20/24
2020
Q & A
Allow time for questions from participants
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
21/24
2121
Test Your Understanding
1. What is MVC pattern?
2. What are the advantages of MVC?
3. List out some of the view components of
Struts Framework.
4. List out some of the Controller component of
Struts Framework.
k
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
22/24
2222
Struts Framework Session 02:Summary
Struts, a Jakarta project hosted by Apache is a
framework for building Web applications based on the
MVC design pattern.
The framework, built upon standard technologies like
Java Servlets, JavaBeans, ResourceBundles.
View is responsible for a presentation view of thebusiness domain.
Controller is responsible for controlling the flow and
state of the user input.
Model is responsible for the business domain state
knowledge.
S k S i 02
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
23/24
2323
Struts Framework Session 02:Source
Programming Jakarta Struts, 2nd Edition
http://java.sun.com/developer/technicalArticles/J2EE/despat/
Disclaimer: Parts of the content of this course is based on the materials available from the Web sites andbooks listed above. The materials that can be accessed from linked sites are not maintained byCognizant Academy and we are not responsible for the contents thereof. All trademarks, service marks,and trade names in this course are the marks of the respective owner(s).
-
8/8/2019 Session 02 Struts Framework Presentation v1.0
24/24
2007, Cognizant Technology Solutions. All Rights Reserved.The information contained herein is subject to change without notice.
You have completed theSession 02 of
Struts Framework.