Struts
Agenda
 Preface
 Struts and its components
 An example
 The architecture required for
Struts Applications
Preface
Problem we faced when designing JSP:
 Familiar with HTML and expertise in web
design (the content, font, color, web page
layout etc.)
 Having Programming knowledge with Java
(embedded java code in JSP)
Break down the
tasks with Struts
What is
Struts
 Norwegian word meaning ostrich
 A Java open source framework
especially used for web application
development.
 With Struts, developers can following
the MVC design pattern to design
web application
What is MVC design pattern
 Input Processing Output
 Controller Model View
Calculation,
database
operation,
connection
with remote
systems
Application
screen, web
pages
Controller in Struts
 Called ActionServlet
 Its functions:
- Receive http request from client
(Web browser)
- Invoke Model part by calling
Action objects
- Send the JSP file returned by
Action objects back to the client
Model component in Struts
 In Action objects
 Its functions:
- Carrying out business related
processing (by itself or other objects)
- Determining the next web page to
send to the client
View component in Struts
 Html and JSP files with Struts tags
embedded
 Features provided by Struts tags:
- Sophisticated html form handling
(validation, error display etc.)
- Display localized messages
stored in a resource file on web
page (message tag)
- And many others …
How to get M V C parts work
together
 A configuration file called struts-
config.xml in XML format
 Defines Action classes, Java Beans used
in the project
 Define “virtual” paths to be used in JSP
files
An
example
In TestWeb1.jsp:
…<struts-html:form action=“action1”>…
In struts-config.xml:
… < action path=“action1”
type=“JavaBean1”…>…
<forward name=“next1"
path="/nextpage1.jsp"/>
 If changing to use another java
bean as Action class in the future,…
The whole process of a client
request
ActionServlet
Action object
JavaBean1
JSP / HTML
files
nextpage1.js
p
Call
“action1”
ActionForward
next1
Client
request
find
The architecture required for Struts Applications
Struts Applications
Struts classes / Taglib
Java Application Server
JSP / Servlet engine
Summary
 Breakdown web development into
MVC parts
 Easy to develop and maintain
Questions
?

Strutsssssssssssssssssssssssssssssssss.ppt

  • 1.
  • 2.
    Agenda  Preface  Strutsand its components  An example  The architecture required for Struts Applications
  • 3.
    Preface Problem we facedwhen designing JSP:  Familiar with HTML and expertise in web design (the content, font, color, web page layout etc.)  Having Programming knowledge with Java (embedded java code in JSP)
  • 4.
  • 5.
    What is Struts  Norwegianword meaning ostrich  A Java open source framework especially used for web application development.  With Struts, developers can following the MVC design pattern to design web application
  • 6.
    What is MVCdesign pattern  Input Processing Output  Controller Model View Calculation, database operation, connection with remote systems Application screen, web pages
  • 7.
    Controller in Struts Called ActionServlet  Its functions: - Receive http request from client (Web browser) - Invoke Model part by calling Action objects - Send the JSP file returned by Action objects back to the client
  • 8.
    Model component inStruts  In Action objects  Its functions: - Carrying out business related processing (by itself or other objects) - Determining the next web page to send to the client
  • 9.
    View component inStruts  Html and JSP files with Struts tags embedded  Features provided by Struts tags: - Sophisticated html form handling (validation, error display etc.) - Display localized messages stored in a resource file on web page (message tag) - And many others …
  • 10.
    How to getM V C parts work together  A configuration file called struts- config.xml in XML format  Defines Action classes, Java Beans used in the project  Define “virtual” paths to be used in JSP files
  • 11.
    An example In TestWeb1.jsp: …<struts-html:form action=“action1”>… Instruts-config.xml: … < action path=“action1” type=“JavaBean1”…>… <forward name=“next1" path="/nextpage1.jsp"/>  If changing to use another java bean as Action class in the future,…
  • 12.
    The whole processof a client request ActionServlet Action object JavaBean1 JSP / HTML files nextpage1.js p Call “action1” ActionForward next1 Client request find
  • 13.
    The architecture requiredfor Struts Applications Struts Applications Struts classes / Taglib Java Application Server JSP / Servlet engine
  • 14.
    Summary  Breakdown webdevelopment into MVC parts  Easy to develop and maintain
  • 15.

Editor's Notes

  • #2 Show arche
  • #11 Same Set .. To be… Then Everything is done