Module 7: Struts 2 Basics  Thanisa Kruawaisayawan   Thanachart Numnonda   www.imcinstitute.com
Apache Struts   Struts is an open source Web application framework    developed as Apache Jakarta project     http://jak...
Why Struts? Takes much of the complexity out of building your  own MVC framework Encourages good design practice and mod...
How Struts 2 Works                     4
Our Goal           5
Steps1. Write JSP pages (View)2. Write Action class (Model)3. Forward at either success or error   through configuration s...
Step 1: Write JSP pages                          7
JSP Pages Write one JSP page for each view Use Struts tags for     Handing  HTML input forms     Writing out messages ...
login.jsp            9
welcome.jsp              10
Step 2: WriteAction classes                 11
Action ClassExtend com.opensymphony.xwork2.ActionSupport  class Decide set of properties that reflect the input form Wri...
LoginAction.java                   13
Step 3: Config  struts.xml                 14
struts.xml   Identify required Actions and then define them as    <action> elements                                      ...
Step 5: Build, Deploy,and Test Application                         16
Results          17
Acknowledgement Most contents are borrowed from thepresentation slides of Sang Shin, Java™Technology Evangelist, Sun Micro...
Thank you   thananum@gmail.comwww.facebook.com/imcinstitute   www.imcinstitute.com                                19
Upcoming SlideShare
Loading in …5
×

Java Web Programming [7/9] : Struts2 Basics

853 views

Published on

Presentation for Java Web Programming Course; 2011

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
853
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
64
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Java Web Programming [7/9] : Struts2 Basics

  1. 1. Module 7: Struts 2 Basics Thanisa Kruawaisayawan Thanachart Numnonda www.imcinstitute.com
  2. 2. Apache Struts Struts is an open source Web application framework developed as Apache Jakarta project  http://jakarta.apache.org/struts/ Model-View-Controller (MVC) framework Used for constructing web applications based Servlets and JSP technologies  Strutsapplication is a genuine Web application that should be able to run on any Servlet container including all Java EE compliant App servers 2
  3. 3. Why Struts? Takes much of the complexity out of building your own MVC framework Encourages good design practice and modeling Easy to learn and use Feature-rich and many supported 3rd-party tools Flexible and extensible Large user community Stable and mature Open source 3
  4. 4. How Struts 2 Works 4
  5. 5. Our Goal 5
  6. 6. Steps1. Write JSP pages (View)2. Write Action class (Model)3. Forward at either success or error through configuration set in struts.xml4. Build, deploy, and test the application 6
  7. 7. Step 1: Write JSP pages 7
  8. 8. JSP Pages Write one JSP page for each view Use Struts tags for  Handing HTML input forms  Writing out messages 8
  9. 9. login.jsp 9
  10. 10. welcome.jsp 10
  11. 11. Step 2: WriteAction classes 11
  12. 12. Action ClassExtend com.opensymphony.xwork2.ActionSupport class Decide set of properties that reflect the input form Write getter and setter methods for each property Write execute() method 12
  13. 13. LoginAction.java 13
  14. 14. Step 3: Config struts.xml 14
  15. 15. struts.xml Identify required Actions and then define them as <action> elements 15
  16. 16. Step 5: Build, Deploy,and Test Application 16
  17. 17. Results 17
  18. 18. Acknowledgement Most contents are borrowed from thepresentation slides of Sang Shin, Java™Technology Evangelist, Sun Microsystems,Inc. 18
  19. 19. Thank you thananum@gmail.comwww.facebook.com/imcinstitute www.imcinstitute.com 19

×