SlideShare a Scribd company logo
1 of 18
Contact us on :
http://vibranttechnologies.co.in/
Contact us on :
http://vibranttechnologies.co.in/
 Introduction
◦ What is Apache Struts?
◦ Overview of traditional JSP/Servlet web applications
 The Model-View-Controller Design Pattern
 Struts’ implementation of the MVC Pattern
◦ ActionServlet
 struts-config.xml
◦ Action Classes
◦ ActionForms
 Validating user input
◦ JSPs and Struts TagLibs
◦ The Model
 Control flow of a typical request to a Struts application
 Additional features
 Summary

Contact us on:
http://vibranttechnologies.co.in/
 Struts is an open-source framework for building more flexible,
maintainable and structured front-ends in Java web applications
 There are two key components in a web application:
◦the data and business logic performed on this data
◦the presentation of data
 Struts
◦helps structuring these components in a Java web app.
◦controls the flow of the web application, strictly
separating these components
◦unifies the interaction between them
 This separation between presentation, business logic and control is
achieved by implementing the Model-View-Controller (MVC)
Design Pattern
Contact us on :
http://vibranttechnologies.co.in/
 Traditionally, there are 3 ways to generate dynamic output (typically HTML or XML) in
Java web applications:
◦ Servlets
 Java classes with some special methods (doGet(), doPost(), …)
 Example: out.println("<H1>" + myString + "</H1>");
 no separation between code and presentation!
◦ JSPs (Java Server Pages)
 HTML (or other) code with embedded Java code (Scriptlets)
 compiled to Servlets when used for the first time
 Example: <H1><% out.println(myString); %></H1>
 better, but still no separation between code and presentation!
◦ JSPs with JSTL (JSP Standard Tag Library)
 JSTL defines a set of tags that can be used within the JSPs
 There are tags for iterations, using JavaBeans, printing
expressions…
 Example: <H1><c:out value="${myBean.myString}"/></H1>
 better readable and thus better maintainability
Contact us on :
http://vibranttechnologies.co.in/
 Splits up responsibilities for handling user interactions in an application into
three layers:
◦Model, View, Controller
 Model
◦ holds application data and business logic
◦ is absolutely independent from the UIs
Contact us on :
http://vibranttechnologies.co.in/
 View
◦ presentation of parts of the Model to the user
◦ independent from the internal implementation of the Model
◦ there can be different Views presenting the same Model data
 Controller
◦ “bridge” between Model and View
◦ controls the flow of the application
 receives/interprets user input
 performs operations on the Model
 triggers View update
 Benefits:
◦ better maintainability and testability of applications
◦ ability to easily develop different kinds of UIs (e.g. console,
GUI, …)
◦ separation of different tasks in development
◦ code reusability
Contact us on :
http://vibranttechnologies.co.in/
 The central component in a Struts application
 manages the flow of the application
◦ receives user requests and delegates them
to the corresponding Action classes
◦ selects the appropriate View to be displayed next
(according to ActionForward returned by an Action class)
 represents a Single Point of Entry of the web application
(Front Controller Pattern)
 implemented as a simple Java Servlet
◦ listed in the deployment descriptor of the surrounding Web
Container (usually web.xml) for handling *.do requests
 can be extended, but in most cases this is not necessary
Contact us on :
http://vibranttechnologies.co.in/
 Struts’ main configuration file
◦used by the ActionServlet
 defines the control flow, the mapping between
components and other global options:
◦ action-mappings
◦ form-beans
◦ forwards
◦ plug-ins
◦…
 can be considered a Struts
internal deployment descriptor
Example:
<struts-config>
<!– [...] -->
<action-mappings>
<action path="/login"
type="app.LoginAction">
<forward name="failure"
path="/login.jsp" />
<forward name="success"
path="/welcome.jsp" />
</action>
</action-mappings>
<!– [...] -->
</struts-config>
Contact us on :
http://vibranttechnologies.co.in/
 perform logic depending on a user’s request
 Actions
◦ are Java classes that extend Struts’ Action
class org.apache.struts.action.Action
◦ The Action's execute() method is called by
the ActionServlet
 Tasks usually performed by Actions:
◦ depending on the type of action:
 perform the action directly (non-complex actions)
 call one or more business logic methods in the Model
◦ return an appropriate ActionForward object that tells the
ActionServlet which View component it should forward to
 Ex.: “failure” or “success” in login application
Contact us on :
http://vibranttechnologies.co.in/
 represent the data stored in HTML forms
◦ hold the state of a form in their properties
◦ provide getter/setter methods to access them
◦ may provide a method to validate form data
 ActionForms
◦ are Java classes that extend Struts’ ActionForm
class org.apache.struts.action.ActionForm
◦ are filled with the form data by the ActionServlet
 one ActionForm can be used for more than one HTML form
◦ very useful when building wizards or similar types of
forms
Contact us on :
http://vibranttechnologies.co.in/
 Validation is done
◦ right in the beginning before the data is used by any
business methods (at this point, validation is limited to the
data structure!)
 Struts offers two options for server-side validation of user input:
◦ the validate() method in ActionForms
 can be implemented by the ActionForm developer
 returns either null (no errors) or an ActionErrors
object
◦ a plug-in to use the Jakarta Commons Validator within Struts
 based on rules defined in an XML file
 there can be one or more rules associated with each property in
a form
 rules can define required fields, min./max. length, range, type
 error messages and rules can be localized using
resource bundles
Contact us on :
http://vibranttechnologies.co.in/
 The presentation layer in a Struts
application is created using standard JSPs
together with some Struts Tag Libraries
 Struts tag libraries
◦ provide access to Model data
◦ enable interaction with ActionForms
◦ provide simple structural logic (such as iteration)
◦...Example:
<%@ prefix="html" uri="/WEB-INF/struts-html.tld" %>
<body>
<html:errors/>
<html:form action="login.do">
Username: <html:text property="username"/><br/>
Password: <html:password property="passwd" redisplay="false"/><br/>
<html:submit>Login</html:submit>
</html:form>
</body>
Contact us on :
http://vibranttechnologies.co.in/
 Holds the data of an application and provides
business logic methods
 Not directly part of the Struts framework!
 The Model is usually built of different kinds
of Business Objects:
◦ JavaBeans
 simple Java classes, that follow certain naming conventions
 contain attributes and corresponding getters/setters
 reside in the Web Container
◦ Enterprise JavaBeans (EJBs)
 components containing business logic in a J2EE architecture
 reside in an EJB Container
 kinds of EJBs: Session Beans, Entity Beans, Message Driven
Beans
 Often a database server is used to make data persistent
Contact us on :
http://vibranttechnologies.co.in/
 Tiles (Struts Plug-In)
◦ many different page components can be
assembled to a “big” page
 very useful when having content that is used on
many different pages (e.g. sidebars)
◦ defined in XML
 Internationalization (i18n)
◦ Struts offers some features to easily
internationalize an application
◦ Text output can be defined in "resource bundles"
that can be provided for many different languages
◦ Struts automatically detects the users language
through the HTTP request
Contact us on :
http://vibranttechnologies.co.in/
 So, why is Struts so useful?
◦ structural separation of data presentation and business
logic
 easy separation of development tasks (web design,
database, …)
 increases maintainability and extendibility (new views!)
 increases reusability of code
◦ Struts provides a Controller that manages the control flow
 changes in the flow can all be done in struts-config.xml
 abstraction from (hard coded) filenames (forwards)
◦ easy localization (internationalization is more important
than ever)
◦ based on standard Java technologies (JSP, Servlets,
JavaBeans)
 thus running on all kinds of JSP/Servlet containers
◦ open-source
 affordable
 no dependence on external companies
 robustness (due to freely accessible source code)
◦ very vivid open-source project with growing developer
community
Contact us on :
http://vibranttechnologies.co.in/

More Related Content

What's hot (20)

Struts Basics
Struts BasicsStruts Basics
Struts Basics
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
Introduction to Struts 1.3
Introduction to Struts 1.3Introduction to Struts 1.3
Introduction to Struts 1.3
 
Struts
StrutsStruts
Struts
 
Step by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts ApplicationStep by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts Application
 
Struts framework
Struts frameworkStruts framework
Struts framework
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overview
 
Jsf Framework
Jsf FrameworkJsf Framework
Jsf Framework
 
Jsp with mvc
Jsp with mvcJsp with mvc
Jsp with mvc
 
Spring Portlet MVC
Spring Portlet MVCSpring Portlet MVC
Spring Portlet MVC
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
 
Java Web Programming [7/9] : Struts2 Basics
Java Web Programming [7/9] : Struts2 BasicsJava Web Programming [7/9] : Struts2 Basics
Java Web Programming [7/9] : Struts2 Basics
 
TY.BSc.IT Java QB U6
TY.BSc.IT Java QB U6TY.BSc.IT Java QB U6
TY.BSc.IT Java QB U6
 
Java server faces
Java server facesJava server faces
Java server faces
 
Spring MVC Basics
Spring MVC BasicsSpring MVC Basics
Spring MVC Basics
 
Struts introduction
Struts introductionStruts introduction
Struts introduction
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
 
Unit 07: Design Patterns and Frameworks (3/3)
Unit 07: Design Patterns and Frameworks (3/3)Unit 07: Design Patterns and Frameworks (3/3)
Unit 07: Design Patterns and Frameworks (3/3)
 
Struts(mrsurwar) ppt
Struts(mrsurwar) pptStruts(mrsurwar) ppt
Struts(mrsurwar) ppt
 
Jsf intro
Jsf introJsf intro
Jsf intro
 

Viewers also liked

Pentaksiran ujian objektif, subjektif, kertas pensil,mpv
Pentaksiran ujian objektif, subjektif, kertas pensil,mpvPentaksiran ujian objektif, subjektif, kertas pensil,mpv
Pentaksiran ujian objektif, subjektif, kertas pensil,mpvSiTi Nurhidayah
 
Lewis Rollins Presentation Business WF.
Lewis Rollins Presentation Business WF.Lewis Rollins Presentation Business WF.
Lewis Rollins Presentation Business WF.Louise Reed
 
Tổng quan về struts framework, mvc
Tổng quan về struts framework, mvc  Tổng quan về struts framework, mvc
Tổng quan về struts framework, mvc truong nguyen
 
Exemplo Negócios Sustentáveis - Prof. Luis Lobão
Exemplo Negócios Sustentáveis - Prof.  Luis LobãoExemplo Negócios Sustentáveis - Prof.  Luis Lobão
Exemplo Negócios Sustentáveis - Prof. Luis LobãoLuis Lobão
 
INFORME AVANCE VALUACION2
INFORME AVANCE VALUACION2INFORME AVANCE VALUACION2
INFORME AVANCE VALUACION2padronreinaldo
 
Le Carnaval de Venise (winton marsalis)
Le Carnaval de Venise (winton marsalis)Le Carnaval de Venise (winton marsalis)
Le Carnaval de Venise (winton marsalis)Partitura de Banda
 
details_calculated
details_calculateddetails_calculated
details_calculatedUsama Khan
 
10 Nuevas Competencias para Enseñar. Philippe Perrenoud
10 Nuevas Competencias para Enseñar. Philippe Perrenoud10 Nuevas Competencias para Enseñar. Philippe Perrenoud
10 Nuevas Competencias para Enseñar. Philippe Perrenoudviribarron
 
Intrada (incluye parte de piano) (trompeta c a. honegger - )
Intrada (incluye parte de piano) (trompeta c   a. honegger - )Intrada (incluye parte de piano) (trompeta c   a. honegger - )
Intrada (incluye parte de piano) (trompeta c a. honegger - )Partitura de Banda
 
POOJA_GUPTA_Resume_1
POOJA_GUPTA_Resume_1POOJA_GUPTA_Resume_1
POOJA_GUPTA_Resume_1pooja gupta
 

Viewers also liked (15)

MCUJournalSpring16 (1)
MCUJournalSpring16 (1)MCUJournalSpring16 (1)
MCUJournalSpring16 (1)
 
Stail pakaian
Stail pakaianStail pakaian
Stail pakaian
 
EMcontro: “Direitos e Proteção Social na EM” - Apresentação
EMcontro: “Direitos e Proteção Social na EM” - ApresentaçãoEMcontro: “Direitos e Proteção Social na EM” - Apresentação
EMcontro: “Direitos e Proteção Social na EM” - Apresentação
 
Pentaksiran ujian objektif, subjektif, kertas pensil,mpv
Pentaksiran ujian objektif, subjektif, kertas pensil,mpvPentaksiran ujian objektif, subjektif, kertas pensil,mpv
Pentaksiran ujian objektif, subjektif, kertas pensil,mpv
 
Lewis Rollins Presentation Business WF.
Lewis Rollins Presentation Business WF.Lewis Rollins Presentation Business WF.
Lewis Rollins Presentation Business WF.
 
Tổng quan về struts framework, mvc
Tổng quan về struts framework, mvc  Tổng quan về struts framework, mvc
Tổng quan về struts framework, mvc
 
A tua glória
A tua glóriaA tua glória
A tua glória
 
A glória da segunda casa
A glória da segunda casaA glória da segunda casa
A glória da segunda casa
 
Exemplo Negócios Sustentáveis - Prof. Luis Lobão
Exemplo Negócios Sustentáveis - Prof.  Luis LobãoExemplo Negócios Sustentáveis - Prof.  Luis Lobão
Exemplo Negócios Sustentáveis - Prof. Luis Lobão
 
INFORME AVANCE VALUACION2
INFORME AVANCE VALUACION2INFORME AVANCE VALUACION2
INFORME AVANCE VALUACION2
 
Le Carnaval de Venise (winton marsalis)
Le Carnaval de Venise (winton marsalis)Le Carnaval de Venise (winton marsalis)
Le Carnaval de Venise (winton marsalis)
 
details_calculated
details_calculateddetails_calculated
details_calculated
 
10 Nuevas Competencias para Enseñar. Philippe Perrenoud
10 Nuevas Competencias para Enseñar. Philippe Perrenoud10 Nuevas Competencias para Enseñar. Philippe Perrenoud
10 Nuevas Competencias para Enseñar. Philippe Perrenoud
 
Intrada (incluye parte de piano) (trompeta c a. honegger - )
Intrada (incluye parte de piano) (trompeta c   a. honegger - )Intrada (incluye parte de piano) (trompeta c   a. honegger - )
Intrada (incluye parte de piano) (trompeta c a. honegger - )
 
POOJA_GUPTA_Resume_1
POOJA_GUPTA_Resume_1POOJA_GUPTA_Resume_1
POOJA_GUPTA_Resume_1
 

Similar to Struts course material

Struts Interview Questions
Struts Interview QuestionsStruts Interview Questions
Struts Interview Questionsjbashask
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksSunil Patil
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworksSunil Patil
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2divzi1913
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2Long Nguyen
 
Server side programming bt0083
Server side programming bt0083Server side programming bt0083
Server side programming bt0083Divyam Pateriya
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts frameworks4al_com
 
Caste a vote online
Caste a vote onlineCaste a vote online
Caste a vote onlineManoj Kumar
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_entechbed
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCAnton Krasnoshchok
 
important struts interview questions
important struts interview questionsimportant struts interview questions
important struts interview questionssurendray
 
vRO Training Document
vRO Training DocumentvRO Training Document
vRO Training DocumentMayank Goyal
 
Netserv Technology Services
Netserv Technology ServicesNetserv Technology Services
Netserv Technology Servicessthicks14
 

Similar to Struts course material (20)

MVC
MVCMVC
MVC
 
Struts Interceptors
Struts InterceptorsStruts Interceptors
Struts Interceptors
 
Struts Interview Questions
Struts Interview QuestionsStruts Interview Questions
Struts Interview Questions
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source Frameworks
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworks
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
Server side programming bt0083
Server side programming bt0083Server side programming bt0083
Server side programming bt0083
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts framework
 
Struts N E W
Struts N E WStruts N E W
Struts N E W
 
Caste a vote online
Caste a vote onlineCaste a vote online
Caste a vote online
 
Ibm
IbmIbm
Ibm
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_en
 
Asp.Net MVC overview
Asp.Net MVC overviewAsp.Net MVC overview
Asp.Net MVC overview
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVC
 
important struts interview questions
important struts interview questionsimportant struts interview questions
important struts interview questions
 
Struts
StrutsStruts
Struts
 
vRO Training Document
vRO Training DocumentvRO Training Document
vRO Training Document
 
Netserv Technology Services
Netserv Technology ServicesNetserv Technology Services
Netserv Technology Services
 
J2EE pattern 5
J2EE pattern 5J2EE pattern 5
J2EE pattern 5
 

More from Vibrant Technologies & Computers

Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Vibrant Technologies & Computers
 

More from Vibrant Technologies & Computers (20)

Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
 
SQL- Introduction to MySQL
SQL- Introduction to MySQLSQL- Introduction to MySQL
SQL- Introduction to MySQL
 
SQL- Introduction to SQL database
SQL- Introduction to SQL database SQL- Introduction to SQL database
SQL- Introduction to SQL database
 
ITIL - introduction to ITIL
ITIL - introduction to ITILITIL - introduction to ITIL
ITIL - introduction to ITIL
 
Salesforce - Introduction to Security & Access
Salesforce -  Introduction to Security & Access Salesforce -  Introduction to Security & Access
Salesforce - Introduction to Security & Access
 
Data ware housing- Introduction to olap .
Data ware housing- Introduction to  olap .Data ware housing- Introduction to  olap .
Data ware housing- Introduction to olap .
 
Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.
 
Data ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housingData ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housing
 
Salesforce - classification of cloud computing
Salesforce - classification of cloud computingSalesforce - classification of cloud computing
Salesforce - classification of cloud computing
 
Salesforce - cloud computing fundamental
Salesforce - cloud computing fundamentalSalesforce - cloud computing fundamental
Salesforce - cloud computing fundamental
 
SQL- Introduction to PL/SQL
SQL- Introduction to  PL/SQLSQL- Introduction to  PL/SQL
SQL- Introduction to PL/SQL
 
SQL- Introduction to advanced sql concepts
SQL- Introduction to  advanced sql conceptsSQL- Introduction to  advanced sql concepts
SQL- Introduction to advanced sql concepts
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
 
SQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set OperationsSQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set Operations
 
Sas - Introduction to designing the data mart
Sas - Introduction to designing the data martSas - Introduction to designing the data mart
Sas - Introduction to designing the data mart
 
Sas - Introduction to working under change management
Sas - Introduction to working under change managementSas - Introduction to working under change management
Sas - Introduction to working under change management
 
SAS - overview of SAS
SAS - overview of SASSAS - overview of SAS
SAS - overview of SAS
 
Teradata - Architecture of Teradata
Teradata - Architecture of TeradataTeradata - Architecture of Teradata
Teradata - Architecture of Teradata
 
Teradata - Restoring Data
Teradata - Restoring Data Teradata - Restoring Data
Teradata - Restoring Data
 

Recently uploaded

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

Struts course material

  • 1.
  • 2. Contact us on : http://vibranttechnologies.co.in/
  • 3. Contact us on : http://vibranttechnologies.co.in/  Introduction ◦ What is Apache Struts? ◦ Overview of traditional JSP/Servlet web applications  The Model-View-Controller Design Pattern  Struts’ implementation of the MVC Pattern ◦ ActionServlet  struts-config.xml ◦ Action Classes ◦ ActionForms  Validating user input ◦ JSPs and Struts TagLibs ◦ The Model  Control flow of a typical request to a Struts application  Additional features  Summary 
  • 4. Contact us on: http://vibranttechnologies.co.in/  Struts is an open-source framework for building more flexible, maintainable and structured front-ends in Java web applications  There are two key components in a web application: ◦the data and business logic performed on this data ◦the presentation of data  Struts ◦helps structuring these components in a Java web app. ◦controls the flow of the web application, strictly separating these components ◦unifies the interaction between them  This separation between presentation, business logic and control is achieved by implementing the Model-View-Controller (MVC) Design Pattern
  • 5. Contact us on : http://vibranttechnologies.co.in/  Traditionally, there are 3 ways to generate dynamic output (typically HTML or XML) in Java web applications: ◦ Servlets  Java classes with some special methods (doGet(), doPost(), …)  Example: out.println("<H1>" + myString + "</H1>");  no separation between code and presentation! ◦ JSPs (Java Server Pages)  HTML (or other) code with embedded Java code (Scriptlets)  compiled to Servlets when used for the first time  Example: <H1><% out.println(myString); %></H1>  better, but still no separation between code and presentation! ◦ JSPs with JSTL (JSP Standard Tag Library)  JSTL defines a set of tags that can be used within the JSPs  There are tags for iterations, using JavaBeans, printing expressions…  Example: <H1><c:out value="${myBean.myString}"/></H1>  better readable and thus better maintainability
  • 6. Contact us on : http://vibranttechnologies.co.in/  Splits up responsibilities for handling user interactions in an application into three layers: ◦Model, View, Controller  Model ◦ holds application data and business logic ◦ is absolutely independent from the UIs
  • 7. Contact us on : http://vibranttechnologies.co.in/  View ◦ presentation of parts of the Model to the user ◦ independent from the internal implementation of the Model ◦ there can be different Views presenting the same Model data  Controller ◦ “bridge” between Model and View ◦ controls the flow of the application  receives/interprets user input  performs operations on the Model  triggers View update  Benefits: ◦ better maintainability and testability of applications ◦ ability to easily develop different kinds of UIs (e.g. console, GUI, …) ◦ separation of different tasks in development ◦ code reusability
  • 8. Contact us on : http://vibranttechnologies.co.in/  The central component in a Struts application  manages the flow of the application ◦ receives user requests and delegates them to the corresponding Action classes ◦ selects the appropriate View to be displayed next (according to ActionForward returned by an Action class)  represents a Single Point of Entry of the web application (Front Controller Pattern)  implemented as a simple Java Servlet ◦ listed in the deployment descriptor of the surrounding Web Container (usually web.xml) for handling *.do requests  can be extended, but in most cases this is not necessary
  • 9. Contact us on : http://vibranttechnologies.co.in/  Struts’ main configuration file ◦used by the ActionServlet  defines the control flow, the mapping between components and other global options: ◦ action-mappings ◦ form-beans ◦ forwards ◦ plug-ins ◦…  can be considered a Struts internal deployment descriptor Example: <struts-config> <!– [...] --> <action-mappings> <action path="/login" type="app.LoginAction"> <forward name="failure" path="/login.jsp" /> <forward name="success" path="/welcome.jsp" /> </action> </action-mappings> <!– [...] --> </struts-config>
  • 10. Contact us on : http://vibranttechnologies.co.in/  perform logic depending on a user’s request  Actions ◦ are Java classes that extend Struts’ Action class org.apache.struts.action.Action ◦ The Action's execute() method is called by the ActionServlet  Tasks usually performed by Actions: ◦ depending on the type of action:  perform the action directly (non-complex actions)  call one or more business logic methods in the Model ◦ return an appropriate ActionForward object that tells the ActionServlet which View component it should forward to  Ex.: “failure” or “success” in login application
  • 11. Contact us on : http://vibranttechnologies.co.in/  represent the data stored in HTML forms ◦ hold the state of a form in their properties ◦ provide getter/setter methods to access them ◦ may provide a method to validate form data  ActionForms ◦ are Java classes that extend Struts’ ActionForm class org.apache.struts.action.ActionForm ◦ are filled with the form data by the ActionServlet  one ActionForm can be used for more than one HTML form ◦ very useful when building wizards or similar types of forms
  • 12. Contact us on : http://vibranttechnologies.co.in/  Validation is done ◦ right in the beginning before the data is used by any business methods (at this point, validation is limited to the data structure!)  Struts offers two options for server-side validation of user input: ◦ the validate() method in ActionForms  can be implemented by the ActionForm developer  returns either null (no errors) or an ActionErrors object ◦ a plug-in to use the Jakarta Commons Validator within Struts  based on rules defined in an XML file  there can be one or more rules associated with each property in a form  rules can define required fields, min./max. length, range, type  error messages and rules can be localized using resource bundles
  • 13. Contact us on : http://vibranttechnologies.co.in/  The presentation layer in a Struts application is created using standard JSPs together with some Struts Tag Libraries  Struts tag libraries ◦ provide access to Model data ◦ enable interaction with ActionForms ◦ provide simple structural logic (such as iteration) ◦...Example: <%@ prefix="html" uri="/WEB-INF/struts-html.tld" %> <body> <html:errors/> <html:form action="login.do"> Username: <html:text property="username"/><br/> Password: <html:password property="passwd" redisplay="false"/><br/> <html:submit>Login</html:submit> </html:form> </body>
  • 14. Contact us on : http://vibranttechnologies.co.in/  Holds the data of an application and provides business logic methods  Not directly part of the Struts framework!  The Model is usually built of different kinds of Business Objects: ◦ JavaBeans  simple Java classes, that follow certain naming conventions  contain attributes and corresponding getters/setters  reside in the Web Container ◦ Enterprise JavaBeans (EJBs)  components containing business logic in a J2EE architecture  reside in an EJB Container  kinds of EJBs: Session Beans, Entity Beans, Message Driven Beans  Often a database server is used to make data persistent
  • 15. Contact us on : http://vibranttechnologies.co.in/  Tiles (Struts Plug-In) ◦ many different page components can be assembled to a “big” page  very useful when having content that is used on many different pages (e.g. sidebars) ◦ defined in XML  Internationalization (i18n) ◦ Struts offers some features to easily internationalize an application ◦ Text output can be defined in "resource bundles" that can be provided for many different languages ◦ Struts automatically detects the users language through the HTTP request
  • 16. Contact us on : http://vibranttechnologies.co.in/  So, why is Struts so useful? ◦ structural separation of data presentation and business logic  easy separation of development tasks (web design, database, …)  increases maintainability and extendibility (new views!)  increases reusability of code ◦ Struts provides a Controller that manages the control flow  changes in the flow can all be done in struts-config.xml  abstraction from (hard coded) filenames (forwards) ◦ easy localization (internationalization is more important than ever) ◦ based on standard Java technologies (JSP, Servlets, JavaBeans)  thus running on all kinds of JSP/Servlet containers ◦ open-source  affordable  no dependence on external companies  robustness (due to freely accessible source code) ◦ very vivid open-source project with growing developer community
  • 17.
  • 18. Contact us on : http://vibranttechnologies.co.in/