SlideShare a Scribd company logo
Introduction to
Jakarta Struts
Framework
The Evolution of Server Side
Web Ap Developement
 CGI(or ISAPI)
 Servlet
 JSP
 JSP+Bean (Model 1)
 JSP+Bean+XML techs
 Model 2 (MVC)
 Model 2X(MVC with XML techs)
What is MVC
 The Model View Controller is a technique used to separate
Business logic/state (the Model) from User Interface (the
View) and program progression/flow (the Control).
 This pattern is very useful when it comes to modern web
development:
– The majority of modern, high usage websites are
dynamically driven.
– People well skilled at presentation (HTML writers) seldom
know how to develop back-end solutions and visa versa.
– Separating business rules from presentation is good no
matter what environment you develop in be it web or
desktop.
資料來源 Craig W. Tataryn ,Introduction to MVC and the Jakarta Struts Framework
Struts
Benefits of MVC
 Promotes Modularity
 I18n
 Abstraction
 Allows application to be defined in a
flow-chart, use-case or activity
diagram which is more easily
transferred to implementation.
資料來源 Craig W. Tataryn ,Introduction to MVC and the Jakarta Struts Framework
The Struts Framework
overview
 Struts is an open source MVC framework developed by the
Apache Jakarta project group.
 Struts allows JSP/Servlet writers the ability to fashion their
web applications using the MVC design pattern.
 By designing your web application using Struts you allow:
– Architect the ability to design using the MVC pattern
– Developer to exploit the Struts framework when building
the app.
– Web designer can learn how to program in MVC.
資料來源 http://jakarta.apache.org/struts/
The Struts Framework
overview(2)
 Struts takes much difficult work out of
developing an MVC based web app.
 The Struts framework provides a collection
of canned objects which can facilitate
fundamental aspects of MVC, while allowing
you to extend further as need suites
Components of Struts
Framework
 Model
– Business Logic Bean(or session
bean) 、 StateBean(or entity
bean) 、 ActionForm 。
 View
– A Set of Tag library.
– Language Resource File
 Controller
– ActionServlet( controlled by struct-configs.xml)
– ActionClasses
 Utility Classes
Components of Struts
Framework(2)
資料來源 http://www-106.ibm.com/developerworks/library/j-struts/?n-j-2151
How Struts works
資料來源 http://www-106.ibm.com/developerworks/library/j-struts/?n-j-2151
View
 The view in Struts is represented by
JSP pages.
 Minimize the occurance of scriptlets in
your page
–Use the tag-library provided by
Struts to control the presenatational
logic.
View:I18n
 The ability to maintain a web app in several
different languages
 Based on the language setup on the client
side, the web app will automatically switch.
 This is achieve in Struts through Java
Resource Bundles
 Instead of having to make a
ResourceBundle class for each language
supported by your web app, resource
bundles can be described as language
resource files
Traditional Chinese English
Demo
View:I18n(2)
 Language Resource
– FileName Conventions
(ResourceName)_(ISO-LanguageCode)_(ISO-ConturyCode).properties
– Register the Resource Name in web.xml.
 In order for web developers to get at
the string resources we use a special
Struts tag called <bean:message/>
View:Example
 Login.jsp
 ApplicationResources_en_US.properti
es
 ApplicationResources_zh_TW.properti
es
Model
 ResultBean,hold information needed
to generate the result page.
 FromBean(extend ActionForm ),hold
the data passed by user either by
POST or Query String.
 Business Logic Bean.
 EJB 、 JMS or other components we
impl at business logic layer before.
Model:ActionForm
 JSP pages acting as the view for this
LogonForm are automatically updated by
Struts with the current values of the
UserName and Password properties.
 If the user changes the properties via the
JSP page, the LogonForm will automatically
be updated by Struts
 Before an ActionForm object is passed to a
controller for processing, a “validate”
method can be implemented on the form
which allows the form to belay processing
until the user fixes invalid input
Model:Example
 LoginForm.java
 tw.edu.nccu.user.TeacherData
Control
 The controller is the switch board of MVC.
 It directs the user to the appropriate views by providing the
view with the correct model
 The task of directing users to appropriate views is called
“mapping” in struts.
 The Struts framework provides a base object called
org.apache.struts.action.ActionServlet.
 The ActionServlet class uses a configuration file called
struts-config.xml to read mapping data called action
mappings
 The ActionServlet class reads the incoming URI and tries to
match the URI against a set of action mappings to see if it can
find a controller class which would be willing to handle the
request
http://TeacherStudata/login.action
Server configured to pass *.action extensions to
org.apache.struts.action.ActionServlet
via a web.xml configuration file
ActionServlet object inspects the URI and tries to match it
against an ActionMapping located in the struts-config.xml file.
Instance of appropriate Action class is found and it’s perform() method is called
Action object handles the request and returns control to a view based where the user is within
the flow of the application
Controller (2)
Control:Example
 tw.edu.nccu.teacherstudata.actions.Lo
ginAction
 Struts-config.xml
 LoginAction.java
Problems with Struts
 Does not work on JDK1.4.0
 Steep learning curve.
 Problems on old Application Servers(include
Tomcat3.2.1 、 Weblogic 5.1).
 The only output document is HTML , it
didn’t support the XSL transform
technology.(Unless we modify the source
code)
Model 2X
 Model2X
– Conceived by Julien Mercay and Gilbert
Bouzeid on Feb 1,2002.
– Replace the JSP+TagLib with XML+XSLT
at presentation layer.
– Using XSL Servlet as the Document
Factory.
– Support pipe-line processing while
generating the target document.
Struts
Struts
Resource
 Struts homepage
– http://jakarta.apache.org/struts/
 Sun’s Servlet Specification
– http://java.sun.com/products/servlet/download.ht
ml#specs
 Sun’s JSP Specification
– http://java.sun.com/products/jsp/download.html
 Blue Stone’s Struts Tutorial
– http://developer.bluestone.com/scripts/SaISAPI.
dll/Gallery.class/demos/trailMaps/index.jsp
 My Struts page
– http://java.cc.nccu.edu.tw/struts/

More Related Content

PPTX
JDBC ppt
PDF
Java Design Patterns Tutorial | Edureka
PDF
07 java collection
PPT
Java Collections Framework
PPT
JDBC Architecture and Drivers
PPTX
Asp.net file types
PDF
Types of UML diagrams
JDBC ppt
Java Design Patterns Tutorial | Edureka
07 java collection
Java Collections Framework
JDBC Architecture and Drivers
Asp.net file types
Types of UML diagrams

What's hot (20)

PPT
Session Tracking in servlets
PPT
Mvc architecture
PPTX
Chapter 3 servlet & jsp
PPT
Java Networking
PPT
Jsp/Servlet
PPTX
Java Server Pages
PPTX
Jdbc ppt
PPTX
Servlets
PPTX
Simple object access protocol(soap )
PPTX
Event In JavaScript
PPTX
Java Beans
PPTX
Java RMI
PPTX
Advance Java Topics (J2EE)
PPTX
Strings in Java
PPT
android activity
PPTX
Introduction to spring boot
PPTX
REST & RESTful Web Services
PPTX
Cohesion and coupling
PPT
Introduction to java beans
PPT
Java Servlets
Session Tracking in servlets
Mvc architecture
Chapter 3 servlet & jsp
Java Networking
Jsp/Servlet
Java Server Pages
Jdbc ppt
Servlets
Simple object access protocol(soap )
Event In JavaScript
Java Beans
Java RMI
Advance Java Topics (J2EE)
Strings in Java
android activity
Introduction to spring boot
REST & RESTful Web Services
Cohesion and coupling
Introduction to java beans
Java Servlets
Ad

Viewers also liked (11)

PPTX
Introduction to ejb and struts framework
PPTX
Struts introduction
PPT
Struts Ppt 1
PPTX
Jsp & struts
PDF
Migrating from Struts 1 to Struts 2
PDF
Struts presentation
PDF
Introduction to Struts 1.3
PDF
Angular JS: First look เริ่มต้น Angular JS กันแบบสบายๆ
PDF
Spring Framework
PDF
เรียนรู้ Node JS แบบสบายๆ สำหรับผู้เริ่มต้น
Introduction to ejb and struts framework
Struts introduction
Struts Ppt 1
Jsp & struts
Migrating from Struts 1 to Struts 2
Struts presentation
Introduction to Struts 1.3
Angular JS: First look เริ่มต้น Angular JS กันแบบสบายๆ
Spring Framework
เรียนรู้ Node JS แบบสบายๆ สำหรับผู้เริ่มต้น
Ad

Similar to Struts (20)

DOCX
Struts ppt 1
PPTX
Skillwise Struts.x
PPTX
struts unit best pdf for struts java.pptx
PPTX
struts unit best pdf for struts java.pptx
DOCX
Struts Interview Questions
PPT
Struts2.x
PPT
Apachecon 2002 Struts
PPT
MVC
PDF
Struts Basics
PPTX
Struts 1
PPTX
PPT
Struts N E W
PDF
Lecture 05 web_applicationframeworks
PPT
Krazykoder struts2 intro
PDF
important struts interview questions
PPT
Struts course material
PPT
141060753008 3715301
PPT
Struts
PPTX
PPTX
Struts Interceptors
Struts ppt 1
Skillwise Struts.x
struts unit best pdf for struts java.pptx
struts unit best pdf for struts java.pptx
Struts Interview Questions
Struts2.x
Apachecon 2002 Struts
MVC
Struts Basics
Struts 1
Struts N E W
Lecture 05 web_applicationframeworks
Krazykoder struts2 intro
important struts interview questions
Struts course material
141060753008 3715301
Struts
Struts Interceptors

More from s4al_com (6)

PPTX
Webservices
PPT
Spring talk111204
PPT
Spring
PPT
Orm and hibernate
PPT
Java
PPT
Online gas booking project in java
Webservices
Spring talk111204
Spring
Orm and hibernate
Java
Online gas booking project in java

Recently uploaded (20)

PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Cell Types and Its function , kingdom of life
PPTX
Institutional Correction lecture only . . .
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
Pre independence Education in Inndia.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Business Ethics Teaching Materials for college
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Cell Types and Its function , kingdom of life
Institutional Correction lecture only . . .
Anesthesia in Laparoscopic Surgery in India
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Pre independence Education in Inndia.pdf
Insiders guide to clinical Medicine.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Renaissance Architecture: A Journey from Faith to Humanism
O7-L3 Supply Chain Operations - ICLT Program
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Business Ethics Teaching Materials for college
VCE English Exam - Section C Student Revision Booklet
Microbial disease of the cardiovascular and lymphatic systems
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf

Struts

  • 2. The Evolution of Server Side Web Ap Developement  CGI(or ISAPI)  Servlet  JSP  JSP+Bean (Model 1)  JSP+Bean+XML techs  Model 2 (MVC)  Model 2X(MVC with XML techs)
  • 3. What is MVC  The Model View Controller is a technique used to separate Business logic/state (the Model) from User Interface (the View) and program progression/flow (the Control).  This pattern is very useful when it comes to modern web development: – The majority of modern, high usage websites are dynamically driven. – People well skilled at presentation (HTML writers) seldom know how to develop back-end solutions and visa versa. – Separating business rules from presentation is good no matter what environment you develop in be it web or desktop. 資料來源 Craig W. Tataryn ,Introduction to MVC and the Jakarta Struts Framework
  • 5. Benefits of MVC  Promotes Modularity  I18n  Abstraction  Allows application to be defined in a flow-chart, use-case or activity diagram which is more easily transferred to implementation. 資料來源 Craig W. Tataryn ,Introduction to MVC and the Jakarta Struts Framework
  • 6. The Struts Framework overview  Struts is an open source MVC framework developed by the Apache Jakarta project group.  Struts allows JSP/Servlet writers the ability to fashion their web applications using the MVC design pattern.  By designing your web application using Struts you allow: – Architect the ability to design using the MVC pattern – Developer to exploit the Struts framework when building the app. – Web designer can learn how to program in MVC. 資料來源 http://jakarta.apache.org/struts/
  • 7. The Struts Framework overview(2)  Struts takes much difficult work out of developing an MVC based web app.  The Struts framework provides a collection of canned objects which can facilitate fundamental aspects of MVC, while allowing you to extend further as need suites
  • 8. Components of Struts Framework  Model – Business Logic Bean(or session bean) 、 StateBean(or entity bean) 、 ActionForm 。  View – A Set of Tag library. – Language Resource File  Controller – ActionServlet( controlled by struct-configs.xml) – ActionClasses  Utility Classes
  • 9. Components of Struts Framework(2) 資料來源 http://www-106.ibm.com/developerworks/library/j-struts/?n-j-2151
  • 10. How Struts works 資料來源 http://www-106.ibm.com/developerworks/library/j-struts/?n-j-2151
  • 11. View  The view in Struts is represented by JSP pages.  Minimize the occurance of scriptlets in your page –Use the tag-library provided by Struts to control the presenatational logic.
  • 12. View:I18n  The ability to maintain a web app in several different languages  Based on the language setup on the client side, the web app will automatically switch.  This is achieve in Struts through Java Resource Bundles  Instead of having to make a ResourceBundle class for each language supported by your web app, resource bundles can be described as language resource files
  • 14. View:I18n(2)  Language Resource – FileName Conventions (ResourceName)_(ISO-LanguageCode)_(ISO-ConturyCode).properties – Register the Resource Name in web.xml.  In order for web developers to get at the string resources we use a special Struts tag called <bean:message/>
  • 16. Model  ResultBean,hold information needed to generate the result page.  FromBean(extend ActionForm ),hold the data passed by user either by POST or Query String.  Business Logic Bean.  EJB 、 JMS or other components we impl at business logic layer before.
  • 17. Model:ActionForm  JSP pages acting as the view for this LogonForm are automatically updated by Struts with the current values of the UserName and Password properties.  If the user changes the properties via the JSP page, the LogonForm will automatically be updated by Struts  Before an ActionForm object is passed to a controller for processing, a “validate” method can be implemented on the form which allows the form to belay processing until the user fixes invalid input
  • 19. Control  The controller is the switch board of MVC.  It directs the user to the appropriate views by providing the view with the correct model  The task of directing users to appropriate views is called “mapping” in struts.  The Struts framework provides a base object called org.apache.struts.action.ActionServlet.  The ActionServlet class uses a configuration file called struts-config.xml to read mapping data called action mappings  The ActionServlet class reads the incoming URI and tries to match the URI against a set of action mappings to see if it can find a controller class which would be willing to handle the request
  • 20. http://TeacherStudata/login.action Server configured to pass *.action extensions to org.apache.struts.action.ActionServlet via a web.xml configuration file ActionServlet object inspects the URI and tries to match it against an ActionMapping located in the struts-config.xml file. Instance of appropriate Action class is found and it’s perform() method is called Action object handles the request and returns control to a view based where the user is within the flow of the application Controller (2)
  • 22. Problems with Struts  Does not work on JDK1.4.0  Steep learning curve.  Problems on old Application Servers(include Tomcat3.2.1 、 Weblogic 5.1).  The only output document is HTML , it didn’t support the XSL transform technology.(Unless we modify the source code)
  • 23. Model 2X  Model2X – Conceived by Julien Mercay and Gilbert Bouzeid on Feb 1,2002. – Replace the JSP+TagLib with XML+XSLT at presentation layer. – Using XSL Servlet as the Document Factory. – Support pipe-line processing while generating the target document.
  • 26. Resource  Struts homepage – http://jakarta.apache.org/struts/  Sun’s Servlet Specification – http://java.sun.com/products/servlet/download.ht ml#specs  Sun’s JSP Specification – http://java.sun.com/products/jsp/download.html  Blue Stone’s Struts Tutorial – http://developer.bluestone.com/scripts/SaISAPI. dll/Gallery.class/demos/trailMaps/index.jsp  My Struts page – http://java.cc.nccu.edu.tw/struts/