SlideShare ist ein Scribd-Unternehmen logo
1 von 14
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

Weitere ähnliche Inhalte

Was ist angesagt?

CDP Proposal
CDP ProposalCDP Proposal
CDP Proposal
tectonar
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 7. struts (20)

Jsf
JsfJsf
Jsf
 
Struts Intro
Struts IntroStruts Intro
Struts Intro
 
08052917365603
0805291736560308052917365603
08052917365603
 
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
 

Mehr von AnusAhmad

Mehr von 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
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 

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