SlideShare a Scribd company logo
IMRAN DAUD
FOUNDATION UNIVERSITY
INSTITUTE OF MANAGEMENT AND
COMPUTER SCIENCES
Imran Daud
FUIMCS
Web Engineering
Struts
What is Struts?
 A framework based on MVC architecture.
Source: java.sun.com
Overview of Struts Application
Creating Struts Application
 Create web Project and select struts as framework.
Action Servlet
Name
Action URL
Pattern
Login.jsp
 Create Login jsp page.
 Add following taglibs i.e. html
 <%@ taglib uri="http://struts.apache.org/tags-html"
prefix="html" %>
 Add form using html
 <html:form action="/login">
 <html:submit value="Login" />
 </html:form>
 Add table using palette and two text fields using html
tag.
success.jsp
 Add bean tag at top of page by using strut bean
taglib.
 Now add following:
ActionForm Bean
 This bean used to persist data between requests.
 When user submits data, it is stored temporarily in
form bean. To be redisplayed in form page in case of
format problem or in success page.
 To add actionForm bean, create new actionForm
bean from strut category and give name
LoginForm.java.
 Add email variable in LoginForm.java bean and add
setter and getter functions.
 After that you can see changes appear in struts-
config.xml file.
Action Class
 When form is received, function of action object is
executed and data is processed. It also decides which
view to forward processed data.
 Create Action Class from wizard from struts category
by giving name LoginAction with following:
Same Path given
in form of login
page
 Associate action class with form bean (LoginForm.java) previously created.
 Delete forward slash from input resource.
 Set scope to Request.
 Deselect the Validate ActionForm Bean option
Validate Form
 Your LoginAction file will look like this:
 It redirects the request for success view.
 But is desirable to validate input before forwarding it to appropriate view.
Validate LoginAction
Adding forward Entries to struts-
config.xml
 In order for the application to match JSP pages with forwarding conditions
returned by LoginAction's execute method, you need to add forward entries to
the struts-config.xml file.
 Open struts-config.xml amd right click anywhere in file.
 select struts and add forward and add following:
Setting welcome page in web.xml
 Goto Page tab og web.xml file and change the
welcome file to login.jsp
 That’s it
Reference
 http://www.csl.mtu.edu/cs2321/
 Netbeans.org
 Roseindia.net
 Jsptut.com
 tutorialspoint.com/jsp
 http://java.sun.com

More Related Content

What's hot

CDP Proposal
CDP ProposalCDP Proposal
CDP Proposal
tectonar
 

What's hot (11)

View
ViewView
View
 
Ppt ch11
Ppt ch11Ppt ch11
Ppt ch11
 
Les04
Les04Les04
Les04
 
Action Guide Reg Process
Action Guide Reg ProcessAction Guide Reg Process
Action Guide Reg Process
 
CDP Proposal
CDP ProposalCDP Proposal
CDP Proposal
 
Lab 2: Importing requirements artifacts from a CSV file
Lab 2: Importing requirements artifacts from a CSV file Lab 2: Importing requirements artifacts from a CSV file
Lab 2: Importing requirements artifacts from a CSV file
 
Metamorphosis from Forms to Java: A technical lead's perspective, part II
Metamorphosis from Forms to Java:  A technical lead's perspective, part IIMetamorphosis from Forms to Java:  A technical lead's perspective, part II
Metamorphosis from Forms to Java: A technical lead's perspective, part II
 
The Ultimate Guide to Ad0 e904 adobe workfront core developer certified exper...
The Ultimate Guide to Ad0 e904 adobe workfront core developer certified exper...The Ultimate Guide to Ad0 e904 adobe workfront core developer certified exper...
The Ultimate Guide to Ad0 e904 adobe workfront core developer certified exper...
 
Les02
Les02Les02
Les02
 
Oracle Forms Creation
Oracle Forms CreationOracle Forms Creation
Oracle Forms Creation
 
Sharepoint 2013
Sharepoint 2013Sharepoint 2013
Sharepoint 2013
 

Viewers also liked

Pesquisa cnt mda_relatorio sintese - cnt junho2013 - r113 - final
Pesquisa cnt mda_relatorio sintese - cnt junho2013 - r113 - finalPesquisa cnt mda_relatorio sintese - cnt junho2013 - r113 - final
Pesquisa cnt mda_relatorio sintese - cnt junho2013 - r113 - final
Folha de Pernambuco
 
Resource management
Resource managementResource management
Resource management
mbondgulo
 
Trabajo grupal 4⺠e.p. grupo b 12. espaã±a en la edad contemporã¡nea (1)
Trabajo grupal 4⺠e.p. grupo b 12. espaã±a en la edad contemporã¡nea  (1)Trabajo grupal 4⺠e.p. grupo b 12. espaã±a en la edad contemporã¡nea  (1)
Trabajo grupal 4⺠e.p. grupo b 12. espaã±a en la edad contemporã¡nea (1)
Richy Perez
 
Rede mundo maior´ apresentação
Rede mundo maior´  apresentaçãoRede mundo maior´  apresentação
Rede mundo maior´ apresentação
Magali Bischoff
 
Where to start with power cli
Where to start with power cliWhere to start with power cli
Where to start with power cli
Chris Halverson
 

Viewers also liked (13)

8. java script
8. java script8. java script
8. java script
 
9. java server faces
9. java server faces9. java server faces
9. java server faces
 
Pesquisa cnt mda_relatorio sintese - cnt junho2013 - r113 - final
Pesquisa cnt mda_relatorio sintese - cnt junho2013 - r113 - finalPesquisa cnt mda_relatorio sintese - cnt junho2013 - r113 - final
Pesquisa cnt mda_relatorio sintese - cnt junho2013 - r113 - final
 
Resource management
Resource managementResource management
Resource management
 
De Eerstelijns Juni 2013
De Eerstelijns Juni 2013De Eerstelijns Juni 2013
De Eerstelijns Juni 2013
 
Paula ardila actividad1_mapc
Paula ardila actividad1_mapcPaula ardila actividad1_mapc
Paula ardila actividad1_mapc
 
Vijay Pandit Palam
Vijay Pandit PalamVijay Pandit Palam
Vijay Pandit Palam
 
Trabajo grupal 4⺠e.p. grupo b 12. espaã±a en la edad contemporã¡nea (1)
Trabajo grupal 4⺠e.p. grupo b 12. espaã±a en la edad contemporã¡nea  (1)Trabajo grupal 4⺠e.p. grupo b 12. espaã±a en la edad contemporã¡nea  (1)
Trabajo grupal 4⺠e.p. grupo b 12. espaã±a en la edad contemporã¡nea (1)
 
1 tg tecnicas de combate al contrabando en fronteras del estado zulia - ruben -
1 tg  tecnicas de combate al contrabando en fronteras del estado zulia - ruben -1 tg  tecnicas de combate al contrabando en fronteras del estado zulia - ruben -
1 tg tecnicas de combate al contrabando en fronteras del estado zulia - ruben -
 
Resolución 030 2015
Resolución 030 2015Resolución 030 2015
Resolución 030 2015
 
Rede mundo maior´ apresentação
Rede mundo maior´  apresentaçãoRede mundo maior´  apresentação
Rede mundo maior´ apresentação
 
Filósofos solares
Filósofos solaresFilósofos solares
Filósofos solares
 
Where to start with power cli
Where to start with power cliWhere to start with power cli
Where to start with power cli
 

Similar to 7. struts

08052917365603
0805291736560308052917365603
08052917365603
DSKUMAR G
 
Cis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry universityCis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry university
lhkslkdh89009
 
Cis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry universityCis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry university
lhkslkdh89009
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
Mani Chaubey
 

Similar to 7. struts (20)

Jsf
JsfJsf
Jsf
 
08052917365603
0805291736560308052917365603
08052917365603
 
Struts Intro
Struts IntroStruts Intro
Struts Intro
 
Struts Overview
Struts OverviewStruts Overview
Struts Overview
 
Cis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry universityCis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry university
 
Struts tutorial
Struts tutorialStruts tutorial
Struts tutorial
 
MVC Training Part 1
MVC Training Part 1MVC Training Part 1
MVC Training Part 1
 
Claims based authentication in share point 2010 .new
Claims based authentication in share point 2010 .newClaims based authentication in share point 2010 .new
Claims based authentication in share point 2010 .new
 
Cis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry universityCis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry university
 
Parallelminds.asp.net with sp
Parallelminds.asp.net with spParallelminds.asp.net with sp
Parallelminds.asp.net with sp
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
 
Chapter12 (1)
Chapter12 (1)Chapter12 (1)
Chapter12 (1)
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
 
Open microsoft visual studio/tutorialoutlet
Open microsoft visual studio/tutorialoutletOpen microsoft visual studio/tutorialoutlet
Open microsoft visual studio/tutorialoutlet
 
Oracle ADF 11g Tutorial
Oracle ADF 11g TutorialOracle ADF 11g Tutorial
Oracle ADF 11g Tutorial
 
Struts N E W
Struts N E WStruts N E W
Struts N E W
 
Web forms in ASP.net
Web forms in ASP.netWeb forms in ASP.net
Web forms in ASP.net
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
 

More from AnusAhmad

More from AnusAhmad (19)

[Www.pkbulk.blogspot.com]file and indexing
[Www.pkbulk.blogspot.com]file and indexing[Www.pkbulk.blogspot.com]file and indexing
[Www.pkbulk.blogspot.com]file and indexing
 
[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12
 
[Www.pkbulk.blogspot.com]dbms11
[Www.pkbulk.blogspot.com]dbms11[Www.pkbulk.blogspot.com]dbms11
[Www.pkbulk.blogspot.com]dbms11
 
[Www.pkbulk.blogspot.com]dbms10
[Www.pkbulk.blogspot.com]dbms10[Www.pkbulk.blogspot.com]dbms10
[Www.pkbulk.blogspot.com]dbms10
 
[Www.pkbulk.blogspot.com]dbms09
[Www.pkbulk.blogspot.com]dbms09[Www.pkbulk.blogspot.com]dbms09
[Www.pkbulk.blogspot.com]dbms09
 
[Www.pkbulk.blogspot.com]dbms07
[Www.pkbulk.blogspot.com]dbms07[Www.pkbulk.blogspot.com]dbms07
[Www.pkbulk.blogspot.com]dbms07
 
[Www.pkbulk.blogspot.com]dbms06
[Www.pkbulk.blogspot.com]dbms06[Www.pkbulk.blogspot.com]dbms06
[Www.pkbulk.blogspot.com]dbms06
 
[Www.pkbulk.blogspot.com]dbms05
[Www.pkbulk.blogspot.com]dbms05[Www.pkbulk.blogspot.com]dbms05
[Www.pkbulk.blogspot.com]dbms05
 
[Www.pkbulk.blogspot.com]dbms04
[Www.pkbulk.blogspot.com]dbms04[Www.pkbulk.blogspot.com]dbms04
[Www.pkbulk.blogspot.com]dbms04
 
[Www.pkbulk.blogspot.com]dbms03
[Www.pkbulk.blogspot.com]dbms03[Www.pkbulk.blogspot.com]dbms03
[Www.pkbulk.blogspot.com]dbms03
 
[Www.pkbulk.blogspot.com]dbms02
[Www.pkbulk.blogspot.com]dbms02[Www.pkbulk.blogspot.com]dbms02
[Www.pkbulk.blogspot.com]dbms02
 
[Www.pkbulk.blogspot.com]dbms01
[Www.pkbulk.blogspot.com]dbms01[Www.pkbulk.blogspot.com]dbms01
[Www.pkbulk.blogspot.com]dbms01
 
[Www.pkbulk.blogspot.com]dbms13
[Www.pkbulk.blogspot.com]dbms13[Www.pkbulk.blogspot.com]dbms13
[Www.pkbulk.blogspot.com]dbms13
 
5. servlets
5. servlets5. servlets
5. servlets
 
4. jsp
4. jsp4. jsp
4. jsp
 
3. applets
3. applets3. applets
3. applets
 
2. http, html
2. http, html2. http, html
2. http, html
 
1. intro
1. intro1. intro
1. intro
 
6. hibernate
6. hibernate6. hibernate
6. hibernate
 

Recently uploaded

The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPost Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 

7. struts

  • 1. IMRAN DAUD FOUNDATION UNIVERSITY INSTITUTE OF MANAGEMENT AND COMPUTER SCIENCES Imran Daud FUIMCS Web Engineering Struts
  • 2. What is Struts?  A framework based on MVC architecture. Source: java.sun.com
  • 3. Overview of Struts Application
  • 4. Creating Struts Application  Create web Project and select struts as framework. Action Servlet Name Action URL Pattern
  • 5. Login.jsp  Create Login jsp page.  Add following taglibs i.e. html  <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>  Add form using html  <html:form action="/login">  <html:submit value="Login" />  </html:form>  Add table using palette and two text fields using html tag.
  • 6. success.jsp  Add bean tag at top of page by using strut bean taglib.  Now add following:
  • 7. ActionForm Bean  This bean used to persist data between requests.  When user submits data, it is stored temporarily in form bean. To be redisplayed in form page in case of format problem or in success page.  To add actionForm bean, create new actionForm bean from strut category and give name LoginForm.java.  Add email variable in LoginForm.java bean and add setter and getter functions.  After that you can see changes appear in struts- config.xml file.
  • 8. Action Class  When form is received, function of action object is executed and data is processed. It also decides which view to forward processed data.  Create Action Class from wizard from struts category by giving name LoginAction with following: Same Path given in form of login page
  • 9.  Associate action class with form bean (LoginForm.java) previously created.  Delete forward slash from input resource.  Set scope to Request.  Deselect the Validate ActionForm Bean option
  • 10. Validate Form  Your LoginAction file will look like this:  It redirects the request for success view.  But is desirable to validate input before forwarding it to appropriate view.
  • 12. Adding forward Entries to struts- config.xml  In order for the application to match JSP pages with forwarding conditions returned by LoginAction's execute method, you need to add forward entries to the struts-config.xml file.  Open struts-config.xml amd right click anywhere in file.  select struts and add forward and add following:
  • 13. Setting welcome page in web.xml  Goto Page tab og web.xml file and change the welcome file to login.jsp  That’s it
  • 14. Reference  http://www.csl.mtu.edu/cs2321/  Netbeans.org  Roseindia.net  Jsptut.com  tutorialspoint.com/jsp  http://java.sun.com