Chaper 2 Struts2 Course Installing and configuring Struts2 & Struts2 Architecture
Struts2 course topics <ul><li>Chapter 1: Evolution of web applications </li></ul><ul><li>Chapter 2: Struts2 Installation a...
Installing and configuring Struts2 <ul><li>Agenda </li></ul><ul><li>Downloading Struts2 </li></ul><ul><li>Installing in a ...
Downloading Struts2
Downloading   Struts2 <ul><li>Download from:  http://struts.apache.org/download.cgi   </li></ul>
Files <ul><li>Release Notes  </li></ul><ul><li>Full Distribution:  </li></ul><ul><ul><li>struts-2.1.6-all.zip (110mb)  </l...
Installing Struts2
Installing Struts2 in a web project Struts.xml is the file where struts is configured Copy the struts2 files into the fold...
Creating the first  struts2 application
Creating the first struts2 application <ul><li>Checking the web.xml </li></ul>< filter > < filter-name > struts2 </ filter...
Creating the first struts2 application <ul><li>Checking the file struts.xml </li></ul>Logical names Action clases JSPs < s...
The file product.jsp   <ul><li><%@   taglib   prefix = &quot;s&quot;   uri = &quot;/struts-tags&quot; %> </li></ul><ul><li...
The file details.jsp <ul><li><%@   taglib   prefix = &quot;s&quot;   uri = &quot;/struts-tags&quot;   %> </li></ul><ul><li...
The action class <ul><li>public   class  Product  implements  Serializable { </li></ul><ul><ul><li>private  String  produc...
Exercise 1 <ul><li>Example of MVC2 implementation  using  Struts2 </li></ul><ul><ul><li>struts2-02a </li></ul></ul>
Exercise 1 <ul><li>Objective </li></ul>Note this
Exercise 1 Model View Controller
Upcoming SlideShare
Loading in...5
×

Struts2 course chapter 2: installation and configuration

5,948

Published on

Struts2 course chapter 2: installation and configuration

Published in: Technology, Education
1 Comment
7 Likes
Statistics
Notes
No Downloads
Views
Total Views
5,948
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
1
Comments
1
Likes
7
Embeds 0
No embeds

No notes for slide

Struts2 course chapter 2: installation and configuration

  1. 1. Chaper 2 Struts2 Course Installing and configuring Struts2 & Struts2 Architecture
  2. 2. Struts2 course topics <ul><li>Chapter 1: Evolution of web applications </li></ul><ul><li>Chapter 2: Struts2 Installation and configuration </li></ul><ul><li>Chapter 3: Actions and results </li></ul><ul><li>Chapter 4: OGNL - Object-Graph Navigation Language </li></ul><ul><li>Chapter 5: Form Tags </li></ul><ul><li>Chapter 6: Generic Tags </li></ul><ul><li>Chapter 7: type conversion </li></ul><ul><li>Chapter 8: Input validation </li></ul><ul><li>Chapter 9: Message Handling and Internationalization </li></ul><ul><li>Chapter 10: Model Driven and Prepare Interceptors </li></ul><ul><li>Chapter 11: The Persistence Layer </li></ul><ul><li>Chapter 12: File upload and File download </li></ul><ul><li>Chapter 13: Securing Struts2 applications in Tomcat </li></ul><ul><li>Chapter 14: Custom Interceptors </li></ul><ul><li>Chapter 15: Custom Result Types </li></ul><ul><li>Chapter 16: Preventing Double Submits </li></ul><ul><li>Chapter 17: The Execute and Wait Interceptor </li></ul><ul><li>Chapter 18: Decorating Struts2 with Tiles </li></ul><ul><li>Chapter 19: Decorating Struts2 with SiteMesh </li></ul><ul><li>Chapter 20: Zero Configuration </li></ul><ul><li>Chapter 21: AJAX </li></ul>
  3. 3. Installing and configuring Struts2 <ul><li>Agenda </li></ul><ul><li>Downloading Struts2 </li></ul><ul><li>Installing in a web project </li></ul><ul><li>Creating the first struts2 application </li></ul><ul><li>Struts2 Architecture </li></ul>
  4. 4. Downloading Struts2
  5. 5. Downloading Struts2 <ul><li>Download from: http://struts.apache.org/download.cgi </li></ul>
  6. 6. Files <ul><li>Release Notes </li></ul><ul><li>Full Distribution: </li></ul><ul><ul><li>struts-2.1.6-all.zip (110mb) </li></ul></ul><ul><li>Example Applications: </li></ul><ul><ul><li>struts-2.1.6-apps.zip (34mb) </li></ul></ul><ul><li>Essential Dependencies Only: </li></ul><ul><ul><li>struts-2.1.6-lib.zip (11mb) </li></ul></ul><ul><li>Documentation: </li></ul><ul><ul><li>struts-2.1.6-docs.zip (60mb) </li></ul></ul><ul><li>Source: </li></ul><ul><ul><li>struts-2.1.6-src.zip (20mb) </li></ul></ul>
  7. 7. Installing Struts2
  8. 8. Installing Struts2 in a web project Struts.xml is the file where struts is configured Copy the struts2 files into the folder: WEB-INF/lib
  9. 9. Creating the first struts2 application
  10. 10. Creating the first struts2 application <ul><li>Checking the web.xml </li></ul>< filter > < filter-name > struts2 </ filter-name > < filter-class > org.apache .struts2.dispatcher.FilterDispatcher </ filter-class > </ filter > < filter-mapping > < filter-name > struts2 </ filter-name > < url-pattern > /* </ url-pattern > </ filter-mapping >
  11. 11. Creating the first struts2 application <ul><li>Checking the file struts.xml </li></ul>Logical names Action clases JSPs < struts > < package name = &quot;app02a&quot; namespace = &quot;“ extends = &quot;struts-default&quot; > < action name = &quot; Product_input &quot; > < result > /jsp/Product.jsp </ result > </ action > < action name = &quot; Product_save” class = &quot; app02a.Product” > < result > /jsp/Details.jsp </ result > </ action > </ package > </ struts >
  12. 12. The file product.jsp <ul><li><%@ taglib prefix = &quot;s&quot; uri = &quot;/struts-tags&quot; %> </li></ul><ul><li>< html > </li></ul><ul><li>< head > </li></ul><ul><ul><li>< title > Add Product Form </ title > </li></ul></ul><ul><ul><li>< style type = &quot;text/css&quot; > </li></ul></ul><ul><ul><li>@import url(css/main.css) ; </li></ul></ul><ul><ul><li></ style > </li></ul></ul><ul><li></ head > </li></ul><ul><li>< body > </li></ul><ul><ul><li>< div id = &quot;global&quot; > </li></ul></ul><ul><ul><ul><li>< h3 > Add a product </ h3 > </li></ul></ul></ul><ul><ul><ul><li>< s:form action = &quot;Product_save&quot; > </li></ul></ul></ul><ul><ul><ul><li>< s:textfield label = &quot;Product Name&quot; key = &quot;productName&quot; /> </li></ul></ul></ul><ul><ul><ul><li>< s:textfield label = &quot;Description&quot; key = &quot;description&quot; /> </li></ul></ul></ul><ul><ul><ul><li><s:textfield label = &quot;Price&quot; key = &quot;price&quot; /> </li></ul></ul></ul><ul><ul><ul><li>< s:submit /> </li></ul></ul></ul><ul><ul><ul><li></ s:form > </li></ul></ul></ul><ul><ul><li></ div > </li></ul></ul><ul><li></ body > </li></ul><ul><li></ html > </li></ul>Properties of the action class
  13. 13. The file details.jsp <ul><li><%@ taglib prefix = &quot;s&quot; uri = &quot;/struts-tags&quot; %> </li></ul><ul><li>< html > </li></ul><ul><li>< head > </li></ul><ul><li>< title > Save Product </ title > </li></ul><ul><li>< style type = &quot;text/css&quot; > @imp o rt url(css/main.c s s); </ style > </li></ul><ul><li></ head > </li></ul><ul><li>< body > </li></ul><ul><ul><li>< div id = &quot;global&quot; > </li></ul></ul><ul><ul><ul><li>< h4 > The product has been saved. </ h4 > </li></ul></ul></ul><ul><ul><ul><li>< p > </li></ul></ul></ul><ul><ul><ul><li>< h5 > Details: </ h5 > </li></ul></ul></ul><ul><ul><ul><li>Product Name: < s:property value = &quot;productName&quot; />< br /> </li></ul></ul></ul><ul><ul><ul><li>Description: < s:property value = &quot;description&quot; />< br /> </li></ul></ul></ul><ul><ul><ul><li>Price: $ < s:property value = &quot;price&quot; /> </li></ul></ul></ul><ul><ul><ul><li></ p > </li></ul></ul></ul><ul><ul><li></ div > </li></ul></ul><ul><li></ body > </li></ul><ul><li></ html > </li></ul>Properties of the action class
  14. 14. The action class <ul><li>public class Product implements Serializable { </li></ul><ul><ul><li>private String productName ; </li></ul></ul><ul><ul><li>private String description ; </li></ul></ul><ul><ul><li>private String price ; </li></ul></ul><ul><ul><li>... </li></ul></ul><ul><ul><li>public String execute () { </li></ul></ul><ul><ul><li>return &quot;success&quot; ; </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><li>} </li></ul>
  15. 15. Exercise 1 <ul><li>Example of MVC2 implementation using Struts2 </li></ul><ul><ul><li>struts2-02a </li></ul></ul>
  16. 16. Exercise 1 <ul><li>Objective </li></ul>Note this
  17. 17. Exercise 1 Model View Controller
  18. 18. Resources To download example code for this chapter go to: http://www.jeetrainers.com http://struts.apache.org

×