SlideShare une entreprise Scribd logo
1  sur  77
STRUTS Part of the Jakarta Project Sponsored by the Apache Software Foundation Developed by: Roger W Barnes of Project Refinery, Inc. Introduction to Struts
STRUTS  Objectives ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  Objectives ,[object Object],[object Object],[object Object],[object Object]
Model-View-Controller Design Pattern Unit 1
STRUTS  MVC Design Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  MVC Design Pattern
STRUTS  MVC Design Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  MVC Design Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object]
Model Components Unit 2
STRUTS  Model Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  Model Components ,[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  Model Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  Model Components ,[object Object],[object Object],[object Object]
STRUTS  Model Components ,[object Object],[object Object],[object Object]
STRUTS  Model Components ,[object Object],[object Object],[object Object]
STRUTS  Model Components ,[object Object],[object Object],[object Object],[object Object]
STRUTS  Model Components ,[object Object],[object Object]
STRUTS  Model Components ,[object Object],[object Object],[object Object]
View Components Unit 3
STRUTS  View Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  View Components ,[object Object],[object Object],[object Object],[object Object]
STRUTS  View Components ,[object Object],[object Object],[object Object]
STRUTS  View Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  View Components ,[object Object],[object Object],[object Object],[object Object]
STRUTS  View Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  View Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  View Components ,[object Object],[object Object],[object Object],[object Object]
STRUTS  View Components ,[object Object],[object Object],[object Object],[object Object]
STRUTS  View Components ,[object Object],[object Object],[object Object],[object Object]
STRUTS  View Components ,[object Object],[object Object],[object Object]
STRUTS  View Components ,[object Object],[object Object],[object Object],[object Object],[object Object]
Controller Components Unit 4
STRUTS  Controller Components ,[object Object]
STRUTS  Controller Components ,[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  Controller Components ,[object Object],[object Object],[object Object]
STRUTS  Controller Components ,[object Object]
STRUTS  Controller Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  Controller Components ,[object Object],[object Object],[object Object]
STRUTS  Controller Components ,[object Object],[object Object],[object Object]
STRUTS  Controller Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  Controller Components ,[object Object],[object Object],[object Object],[object Object]
STRUTS  Controller Components ,[object Object],[object Object],[object Object]
STRUTS  Controller Components ,[object Object],[object Object],[object Object],[object Object]
STRUTS  Controller Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
STRUTS  Controller Components ,[object Object],[object Object]
Tag Libraries Unit 5
STRUTS  Tag Libraries ,[object Object],[object Object],[object Object],[object Object],[object Object]
HTML Tags ,[object Object]
HTML Tags ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
HTML Tags  – Typical HTML Form <HTML> <BODY> <FORM> <TABLE WIDTH=&quot;100%&quot;> <TR><TD>First Name</TD> <TD><INPUT TYPE=&quot;TEXT&quot; NAME=&quot;Name&quot; SIZE=&quot;40&quot; MAXLENGTH=&quot;40&quot;></TD></TR> <TR><TD>Street Address</TD> <TD><INPUT TYPE=&quot;TEXT&quot; NAME=&quot;Address&quot; SIZE=&quot;40&quot; MAXLENGTH=&quot;40&quot;></TD></TR> <TR><TD>City</TD> <TD><INPUT TYPE=&quot;TEXT&quot; NAME=&quot;City&quot; SIZE=&quot;20&quot; MAXLENGTH=&quot;20&quot;></TD></TR> <TR><TD>State</TD> <TD><INPUT TYPE=&quot;TEXT&quot; NAME=&quot;State&quot; SIZE=&quot;2&quot; MAXLENGTH=&quot;2&quot;></TD></TR> <TR><TD>Postal Code</TD> <TD><INPUT TYPE=&quot;TEXT&quot; NAME=&quot;ZipCode&quot; SIZE=&quot;9&quot; MAXLENGTH=&quot;9&quot;></TD></TR> <TR><TD ALIGN=CENTER><INPUT TYPE=&quot;SUBMIT&quot; NAME=&quot;Submit&quot; VALUE=&quot;Save&quot;></TD> <TD><INPUT TYPE=&quot;RESET&quot; NAME=&quot;Reset&quot; VALUE=&quot;Cancel&quot;></TD></TR> </TABLE> </FORM> </BODY> </HTML>
HTML Tags  – Typical Struts Form <HTML:HTML> <BODY> <HTML:FORM Action=&quot;/CustomerForm&quot; focus=“name” > <TABLE WIDTH=&quot;100%&quot;> <TR><TD><bean:message key=&quot;customer.name&quot;/></TD> <TD><HTML:TEXT property=&quot;name&quot; size=&quot;40&quot; maxlength=&quot;40&quot; /></TD></TR> <TR><TD><bean:message key=&quot;customer.address&quot;/></TD> <TD><HTML:TEXT property=&quot;address&quot; size =&quot;40&quot; maxlength =&quot;40&quot; /></TD></TR> <TR><TD><bean:message key=&quot;customer.city&quot;/></TD> <TD><HTML:TEXT property=&quot;city&quot; size =&quot;20&quot; maxlength =&quot;20&quot; /></TD></TR> <TR><TD><bean:message key=&quot;customer.state&quot;/></TD> <TD><HTML:TEXT property=&quot;state&quot; size =&quot;2&quot; maxlength =&quot;2&quot; /></TD></TR> <TR><TD><bean:message key=&quot;customer.zip&quot;/></TD> <TD><HTML:TEXT property=&quot;zip&quot; size =&quot;9&quot; maxlength =&quot;9&quot; /></TD></TR> <TR><TD ALIGN=CENTER><html:submit property=&quot;action&quot; value =&quot;Save&quot;/></TD> <TD><html:reset property=&quot;action&quot; value =&quot;Reset&quot;/></TD></TR> </TABLE> </HTML:FORM> </BODY> </HTML:HTML>
Bean Tags ,[object Object],[object Object],[object Object],[object Object]
Bean Tags   Tag Name Description cookie Define a scripting variable based on the value(s) of the specified request cookie.  define Define a scripting variable based on the value(s) of the specified bean property.  header Define a scripting variable based on the value(s) of the specified request header.  include Load the response from a dynamic application request and make it available as a bean.  message Render an internationalized message string to the response.  page Expose a specified item from the page context as a bean.  parameter Define a scripting variable based on the value(s) of the specified request parameter.  resource Load a web application resource and make it available as a bean.  size Define a bean containing the number of elements in a Collection or Map.  struts Expose a named Struts internal configuration object as a bean.  write Render the value of the specified bean property to the current JspWriter.
Bean Tag Example <table border=&quot;2&quot;> <tr> <th align=&quot;left&quot;><bean:message key=“imagebroker.lob”/></th> <th align=&quot;left&quot;><bean:message key=“imagebroker.unitnbr”/></th> <th align=&quot;left&quot;><bean:message key=“imagebroker.onbase_dns”/></th> </tr> <logic:iterate id=&quot;image&quot; property=&quot;collection&quot;  name=&quot;ImageLocationListForm&quot;> <tr> <td><a href=&quot;ImageLocationListForm.do?lob=<bean:write name='image'  property='lob'/> &unitnbr=<bean:write name='image' property='unitnbr'/> &onbase_dns=<bean:write name='image' property='onbase_dns'/>&quot; > <bean:write name=&quot;image&quot; property=&quot;lob&quot;/></a></td> <td><bean:write name=&quot;image&quot; property=&quot;unitnbr&quot;/></td>  <td><bean:write name=&quot;image&quot; property=&quot;onbase_dns&quot;/></td>  </tr> </logic:iterate> </table>
Logic Tags ,[object Object]
Logic Tags ,[object Object],[object Object],[object Object],[object Object],[object Object]
Logic Tags ,[object Object],[object Object],[object Object],[object Object]
Logic Tags   Tag Name Description empty Evaluate the nested body content of this tag if the requested variable is either null or an empty string.  equal Evaluate the nested body content of this tag if the requested variable is equal to the specified value.  forward Forward control to the page specified by the specified ActionForward entry.  greaterEqual Evaluate the nested body content of this tag if requested variable is greater than or equal to specified value.  greaterThan Evaluate the nested body content of this tag if the requested variable is greater than the specified value.  iterate Repeat the nested body content of this tag over a specified collection.  lessEqual Evaluate the nested body content of this tag if requested variable is greater than or equal to specified value.  lessThan Evaluate the nested body content of this tag if the requested variable is less than the specified value.  match Evaluate the nested body content of this tag if specified value is an appropriate substring of requested variable.  messagesNotPresent Generate the nested body content of this tag if the specified message is not present in this request.  messagesPresent Generate the nested body content of this tag if the specified message is present in this request.  notEmpty Evaluate the nested body content of this tag if the requested variable is neither null nor an empty string.  notEqual Evaluate the nested body content of this tag if the requested variable is not equal to the specified value.  notMatch Evaluate the nested body content of tag if specified value not an appropriate substring of requested variable.  notPresent Generate the nested body content of this tag if the specified value is not present in this request.  present Generate the nested body content of this tag if the specified value is present in this request.  redirect Render an HTTP Redirect
Logic Tags - Example <html:html> <head> <title><bean:message key=&quot;imagebrokerlink.title&quot;/></title> <META name=&quot;GENERATOR&quot; content=&quot;IBM WebSphere Studio&quot;> </head> <body> <html:form action=&quot;/ImageLocationForm&quot; > <center> <font size=3> <br> <b> <logic:notEqual property=&quot;action&quot; name=&quot;ImageLocationForm&quot; value=&quot;Insert&quot;> <bean:message key=&quot;imagelocationdetail.title&quot;/> </logic:notEqual> <logic:equal property=&quot;action&quot; name=&quot;ImageLocationForm&quot; value=&quot;Insert&quot;> <bean:message key=&quot;imagelocationinsert.title&quot;/> </logic:equal> … …
Template Tags ,[object Object]
Template Tags ,[object Object],[object Object],[object Object]
Custom Tags  <%@ taglib uri=&quot;WEB-INF/imagebroker.tld&quot; prefix=&quot;broker&quot; %> <table width=750 cellspacing=0 cellpadding=2 border=2 > <tr> <td><broker:form  lob='<%=test.getLob()%>'  unitnbr='<%=test.getUnitnbr()%>'  userid='<%=test.getUserid()%>' > <broker:doctype value=&quot;Invoice&quot;/> <broker:keyword name=&quot;CompanyNbr&quot; value=&quot;55555&quot;/> <broker:keyword name=&quot;PONbr&quot; value=&quot;M12345&quot;/> <broker:constraint name=&quot;FromDate&quot; value=&quot;02/02/2002&quot;/> <broker:constraint name=&quot;ToDate&quot; value=&quot;02/28/2002&quot;/> Image Broker Link Test </broker:form> </td> </tr> </table>
Custom Tags – tld File <tag> <name>doctype</name> <tagclass>com.pri.brokertag.ImageBrokerDoctype</tagclass> <attribute> <name>value</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> </tag>
Custom Tags – Tag Class public class ImageBrokerDoctype extends TagSupport { private String value = null; public int doStartTag() throws JspException { Hashtable ht = null; String keyword_count = null; int iCnt = 0; HttpServletRequest request = (HttpServletRequest)    pageContext.getRequest(); ht = (Hashtable) request.getAttribute(&quot;keyword_parms&quot;); keyword_count = (String)        request.getAttribute(&quot;queryobject_count&quot;); iCnt ++; ht.put(&quot;QueryObject&quot; + iCnt, value); request.setAttribute(&quot;keyword_parms&quot;, ht); request.setAttribute(&quot;queryobject_count&quot;, new String(new    Integer(iCnt).toString())); return EVAL_PAGE;  } }
STRUTS Configuration File Unit 6
STRUTS Configuration File ,[object Object]
STRUTS Configuration File ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Struts-config.xml <?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?> <!DOCTYPE struts-config PUBLIC &quot;-//Apache Software Foundation//DTD Struts Configuration 1.0//EN&quot; &quot;http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd&quot;> <struts-config> <!-- ========== Form Bean Definitions =================================== --> <form-beans> <form-bean  name=&quot;CryptForm&quot; type=&quot;com.pri.imagebrokerWeb.CryptForm&quot; /> </form-beans> <!-- ========== Global Forward Definitions ============================== --> <global-forwards> <forward name=&quot;start&quot; path=&quot;/index.html&quot;/> </global-forwards> <!-- ========== Action Mapping Definitions ============================== --> <action-mappings> <action  path=&quot;/CryptForm&quot; type=&quot;com.pri.imagebrokerWeb.CryptAction&quot;  name=&quot;CryptForm&quot;  scope=&quot;request&quot;  input=&quot;/pgCrypt.jsp&quot;> <forward name=&quot;encrypt&quot;  path=&quot;/pgCryptDisplay.jsp&quot;/> </action> </action-mappings> </struts-config>
Web Application Descriptor File Unit 7
Web.xml File ,[object Object]
Web.xml File <?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?> <!DOCTYPE web-app PUBLIC &quot;-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN&quot; &quot;http://java.sun.com/j2ee/dtds/web-app_2_2.dtd&quot;> <web-app id=&quot;WebApp&quot;> <display-name>imagebrokerWeb</display-name> <!-- Action Servlet Configuration --> <servlet id=&quot;Servlet_1&quot;> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>application</param-name><param-value>imagebrokerWeb</param-value> </init-param> <init-param> <param-name>config</param-name><param-value>WEB-INF/struts-config.xml</param-value> </init-param> </servlet>
Web.xml File - continued <!-- Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- The Welcome File List --> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list>
Web.xml File - continued <!-- Struts Tag Library Descriptors --> <taglib> <taglib-uri>WEB-INF/struts-bean.tld</taglib-uri> <taglib-location>/WEB-INF/struts-bean.tld</taglib-location> </taglib> <taglib> <taglib-uri>WEB-INF/struts-html.tld</taglib-uri> <taglib-location>/WEB-INF/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>WEB-INF/struts-logic.tld</taglib-uri> <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> </taglib> </web-app>
Application Resources File Unit 8
Application.properties File error.cryptvalue.required=<li>You must enter some text.</li> error.lob.required=<li>You must enter the Line of Business.</li> error.unitnbr.required=<li>You must enter the Unit Number.</li> error.onbase_dns.required=<li>You must enter the OnBase DNS.</li> imagebroker.linkname=Project Refinery, Inc. imagebroker.title=pri Image Broker imagebrokerlink.title=pri Image Broker Link Test imagelocationlist.title=Image Location List imagelocationdetail.title=Image Location Detail imagelocationinsert.title=Image Location Insert errors.header= errors.footer=
Resources Unit 9
Resources ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Contenu connexe

Tendances

Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
BG Java EE Course
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
Guy Nir
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_en
techbed
 

Tendances (19)

Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 
Jsp advance part i
Jsp advance part iJsp advance part i
Jsp advance part i
 
Spring MVC Basics
Spring MVC BasicsSpring MVC Basics
Spring MVC Basics
 
Annotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCAnnotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVC
 
Spring mvc 2.0
Spring mvc 2.0Spring mvc 2.0
Spring mvc 2.0
 
Hibernate III
Hibernate IIIHibernate III
Hibernate III
 
JSP Technology I
JSP Technology IJSP Technology I
JSP Technology I
 
.NET Core, ASP.NET Core Course, Session 11
.NET Core, ASP.NET Core Course, Session 11.NET Core, ASP.NET Core Course, Session 11
.NET Core, ASP.NET Core Course, Session 11
 
Struts course material
Struts course materialStruts course material
Struts course material
 
Rational Publishing Engine and Rational RequisitePro
Rational Publishing Engine and Rational  RequisiteProRational Publishing Engine and Rational  RequisitePro
Rational Publishing Engine and Rational RequisitePro
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
 
Spring Framework-II
Spring Framework-IISpring Framework-II
Spring Framework-II
 
Spring MVC 3.0 Framework
Spring MVC 3.0 FrameworkSpring MVC 3.0 Framework
Spring MVC 3.0 Framework
 
What is struts_en
What is struts_enWhat is struts_en
What is struts_en
 
Spring Framework - III
Spring Framework - IIISpring Framework - III
Spring Framework - III
 
Jsf
JsfJsf
Jsf
 
.NET Core, ASP.NET Core Course, Session 10
.NET Core, ASP.NET Core Course, Session 10.NET Core, ASP.NET Core Course, Session 10
.NET Core, ASP.NET Core Course, Session 10
 
Spring MVC Architecture Tutorial
Spring MVC Architecture TutorialSpring MVC Architecture Tutorial
Spring MVC Architecture Tutorial
 

Similaire à Struts Intro Course(1)

Struts Introduction Course
Struts Introduction CourseStruts Introduction Course
Struts Introduction Course
guest764934
 
Asp Net Advance Topics
Asp Net Advance TopicsAsp Net Advance Topics
Asp Net Advance Topics
Ali Taki
 
Apachecon 2002 Struts
Apachecon 2002 StrutsApachecon 2002 Struts
Apachecon 2002 Struts
yesprakash
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
Dilip Patel
 
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
Sunil 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 frameworks
Sunil Patil
 

Similaire à Struts Intro Course(1) (20)

Struts N E W
Struts N E WStruts N E W
Struts N E W
 
Struts Introduction Course
Struts Introduction CourseStruts Introduction Course
Struts Introduction Course
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
 
MVC
MVCMVC
MVC
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
 
Struts 2
Struts 2Struts 2
Struts 2
 
Asp Net Advance Topics
Asp Net Advance TopicsAsp Net Advance Topics
Asp Net Advance Topics
 
Struts Ppt 1
Struts Ppt 1Struts Ppt 1
Struts Ppt 1
 
Spring from a to Z
Spring from  a to ZSpring from  a to Z
Spring from a to Z
 
Apachecon 2002 Struts
Apachecon 2002 StrutsApachecon 2002 Struts
Apachecon 2002 Struts
 
Introduction to Alfresco Surf Platform
Introduction to Alfresco Surf PlatformIntroduction to Alfresco Surf Platform
Introduction to Alfresco Surf Platform
 
Html JavaScript and CSS
Html JavaScript and CSSHtml JavaScript and CSS
Html JavaScript and CSS
 
Struts ppt 1
Struts ppt 1Struts ppt 1
Struts ppt 1
 
Migration from ASP to ASP.NET
Migration from ASP to ASP.NETMigration from ASP to ASP.NET
Migration from ASP to ASP.NET
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
Struts
StrutsStruts
Struts
 
Session 1
Session 1Session 1
Session 1
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
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
 

Plus de wangjiaz

We9 Struts 2.0
We9 Struts 2.0We9 Struts 2.0
We9 Struts 2.0
wangjiaz
 
Workshop Sutdio3(1)
Workshop Sutdio3(1)Workshop Sutdio3(1)
Workshop Sutdio3(1)
wangjiaz
 
Ye Ying(1)
Ye Ying(1)Ye Ying(1)
Ye Ying(1)
wangjiaz
 
Zhanbin Web2.0
Zhanbin Web2.0Zhanbin Web2.0
Zhanbin Web2.0
wangjiaz
 
U Co M Protocol
U Co M ProtocolU Co M Protocol
U Co M Protocol
wangjiaz
 
Tt Seminar Taipei 9605(1)
Tt Seminar Taipei 9605(1)Tt Seminar Taipei 9605(1)
Tt Seminar Taipei 9605(1)
wangjiaz
 
The New Iphone
The New IphoneThe New Iphone
The New Iphone
wangjiaz
 
Struts Mitac(1)
Struts Mitac(1)Struts Mitac(1)
Struts Mitac(1)
wangjiaz
 
Sxdylgn(1)
Sxdylgn(1)Sxdylgn(1)
Sxdylgn(1)
wangjiaz
 
S11flash(1)
S11flash(1)S11flash(1)
S11flash(1)
wangjiaz
 
Role Play Exercises
Role Play ExercisesRole Play Exercises
Role Play Exercises
wangjiaz
 
Recruit(1)
Recruit(1)Recruit(1)
Recruit(1)
wangjiaz
 
web 2.0 class notes
web 2.0 class notesweb 2.0 class notes
web 2.0 class notes
wangjiaz
 
Ye Ying(1)
Ye Ying(1)Ye Ying(1)
Ye Ying(1)
wangjiaz
 
Xzzx20060302 1
Xzzx20060302 1Xzzx20060302 1
Xzzx20060302 1
wangjiaz
 

Plus de wangjiaz (20)

We9 Struts 2.0
We9 Struts 2.0We9 Struts 2.0
We9 Struts 2.0
 
Workshop Sutdio3(1)
Workshop Sutdio3(1)Workshop Sutdio3(1)
Workshop Sutdio3(1)
 
Ye Ying(1)
Ye Ying(1)Ye Ying(1)
Ye Ying(1)
 
Zhanbin Web2.0
Zhanbin Web2.0Zhanbin Web2.0
Zhanbin Web2.0
 
U Co M Protocol
U Co M ProtocolU Co M Protocol
U Co M Protocol
 
Tt Seminar Taipei 9605(1)
Tt Seminar Taipei 9605(1)Tt Seminar Taipei 9605(1)
Tt Seminar Taipei 9605(1)
 
The New Iphone
The New IphoneThe New Iphone
The New Iphone
 
Struts Mitac(1)
Struts Mitac(1)Struts Mitac(1)
Struts Mitac(1)
 
Sxdylgn(1)
Sxdylgn(1)Sxdylgn(1)
Sxdylgn(1)
 
Sjjz6(1)
Sjjz6(1)Sjjz6(1)
Sjjz6(1)
 
Sjjz5(1)
Sjjz5(1)Sjjz5(1)
Sjjz5(1)
 
S11flash(1)
S11flash(1)S11flash(1)
S11flash(1)
 
Role Play Exercises
Role Play ExercisesRole Play Exercises
Role Play Exercises
 
Recruit(1)
Recruit(1)Recruit(1)
Recruit(1)
 
114
114114
114
 
web 2.0 class notes
web 2.0 class notesweb 2.0 class notes
web 2.0 class notes
 
Yxch
YxchYxch
Yxch
 
Ye Ying(1)
Ye Ying(1)Ye Ying(1)
Ye Ying(1)
 
Xzzx20060302 1
Xzzx20060302 1Xzzx20060302 1
Xzzx20060302 1
 
Xcz
XczXcz
Xcz
 

Dernier

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Struts Intro Course(1)

  • 1. STRUTS Part of the Jakarta Project Sponsored by the Apache Software Foundation Developed by: Roger W Barnes of Project Refinery, Inc. Introduction to Struts
  • 2.
  • 3.
  • 5.
  • 6. STRUTS MVC Design Pattern
  • 7.
  • 8.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 47.
  • 48.
  • 49.
  • 50. HTML Tags – Typical HTML Form <HTML> <BODY> <FORM> <TABLE WIDTH=&quot;100%&quot;> <TR><TD>First Name</TD> <TD><INPUT TYPE=&quot;TEXT&quot; NAME=&quot;Name&quot; SIZE=&quot;40&quot; MAXLENGTH=&quot;40&quot;></TD></TR> <TR><TD>Street Address</TD> <TD><INPUT TYPE=&quot;TEXT&quot; NAME=&quot;Address&quot; SIZE=&quot;40&quot; MAXLENGTH=&quot;40&quot;></TD></TR> <TR><TD>City</TD> <TD><INPUT TYPE=&quot;TEXT&quot; NAME=&quot;City&quot; SIZE=&quot;20&quot; MAXLENGTH=&quot;20&quot;></TD></TR> <TR><TD>State</TD> <TD><INPUT TYPE=&quot;TEXT&quot; NAME=&quot;State&quot; SIZE=&quot;2&quot; MAXLENGTH=&quot;2&quot;></TD></TR> <TR><TD>Postal Code</TD> <TD><INPUT TYPE=&quot;TEXT&quot; NAME=&quot;ZipCode&quot; SIZE=&quot;9&quot; MAXLENGTH=&quot;9&quot;></TD></TR> <TR><TD ALIGN=CENTER><INPUT TYPE=&quot;SUBMIT&quot; NAME=&quot;Submit&quot; VALUE=&quot;Save&quot;></TD> <TD><INPUT TYPE=&quot;RESET&quot; NAME=&quot;Reset&quot; VALUE=&quot;Cancel&quot;></TD></TR> </TABLE> </FORM> </BODY> </HTML>
  • 51. HTML Tags – Typical Struts Form <HTML:HTML> <BODY> <HTML:FORM Action=&quot;/CustomerForm&quot; focus=“name” > <TABLE WIDTH=&quot;100%&quot;> <TR><TD><bean:message key=&quot;customer.name&quot;/></TD> <TD><HTML:TEXT property=&quot;name&quot; size=&quot;40&quot; maxlength=&quot;40&quot; /></TD></TR> <TR><TD><bean:message key=&quot;customer.address&quot;/></TD> <TD><HTML:TEXT property=&quot;address&quot; size =&quot;40&quot; maxlength =&quot;40&quot; /></TD></TR> <TR><TD><bean:message key=&quot;customer.city&quot;/></TD> <TD><HTML:TEXT property=&quot;city&quot; size =&quot;20&quot; maxlength =&quot;20&quot; /></TD></TR> <TR><TD><bean:message key=&quot;customer.state&quot;/></TD> <TD><HTML:TEXT property=&quot;state&quot; size =&quot;2&quot; maxlength =&quot;2&quot; /></TD></TR> <TR><TD><bean:message key=&quot;customer.zip&quot;/></TD> <TD><HTML:TEXT property=&quot;zip&quot; size =&quot;9&quot; maxlength =&quot;9&quot; /></TD></TR> <TR><TD ALIGN=CENTER><html:submit property=&quot;action&quot; value =&quot;Save&quot;/></TD> <TD><html:reset property=&quot;action&quot; value =&quot;Reset&quot;/></TD></TR> </TABLE> </HTML:FORM> </BODY> </HTML:HTML>
  • 52.
  • 53. Bean Tags   Tag Name Description cookie Define a scripting variable based on the value(s) of the specified request cookie. define Define a scripting variable based on the value(s) of the specified bean property. header Define a scripting variable based on the value(s) of the specified request header. include Load the response from a dynamic application request and make it available as a bean. message Render an internationalized message string to the response. page Expose a specified item from the page context as a bean. parameter Define a scripting variable based on the value(s) of the specified request parameter. resource Load a web application resource and make it available as a bean. size Define a bean containing the number of elements in a Collection or Map. struts Expose a named Struts internal configuration object as a bean. write Render the value of the specified bean property to the current JspWriter.
  • 54. Bean Tag Example <table border=&quot;2&quot;> <tr> <th align=&quot;left&quot;><bean:message key=“imagebroker.lob”/></th> <th align=&quot;left&quot;><bean:message key=“imagebroker.unitnbr”/></th> <th align=&quot;left&quot;><bean:message key=“imagebroker.onbase_dns”/></th> </tr> <logic:iterate id=&quot;image&quot; property=&quot;collection&quot; name=&quot;ImageLocationListForm&quot;> <tr> <td><a href=&quot;ImageLocationListForm.do?lob=<bean:write name='image' property='lob'/> &unitnbr=<bean:write name='image' property='unitnbr'/> &onbase_dns=<bean:write name='image' property='onbase_dns'/>&quot; > <bean:write name=&quot;image&quot; property=&quot;lob&quot;/></a></td> <td><bean:write name=&quot;image&quot; property=&quot;unitnbr&quot;/></td> <td><bean:write name=&quot;image&quot; property=&quot;onbase_dns&quot;/></td> </tr> </logic:iterate> </table>
  • 55.
  • 56.
  • 57.
  • 58. Logic Tags   Tag Name Description empty Evaluate the nested body content of this tag if the requested variable is either null or an empty string. equal Evaluate the nested body content of this tag if the requested variable is equal to the specified value. forward Forward control to the page specified by the specified ActionForward entry. greaterEqual Evaluate the nested body content of this tag if requested variable is greater than or equal to specified value. greaterThan Evaluate the nested body content of this tag if the requested variable is greater than the specified value. iterate Repeat the nested body content of this tag over a specified collection. lessEqual Evaluate the nested body content of this tag if requested variable is greater than or equal to specified value. lessThan Evaluate the nested body content of this tag if the requested variable is less than the specified value. match Evaluate the nested body content of this tag if specified value is an appropriate substring of requested variable. messagesNotPresent Generate the nested body content of this tag if the specified message is not present in this request. messagesPresent Generate the nested body content of this tag if the specified message is present in this request. notEmpty Evaluate the nested body content of this tag if the requested variable is neither null nor an empty string. notEqual Evaluate the nested body content of this tag if the requested variable is not equal to the specified value. notMatch Evaluate the nested body content of tag if specified value not an appropriate substring of requested variable. notPresent Generate the nested body content of this tag if the specified value is not present in this request. present Generate the nested body content of this tag if the specified value is present in this request. redirect Render an HTTP Redirect
  • 59. Logic Tags - Example <html:html> <head> <title><bean:message key=&quot;imagebrokerlink.title&quot;/></title> <META name=&quot;GENERATOR&quot; content=&quot;IBM WebSphere Studio&quot;> </head> <body> <html:form action=&quot;/ImageLocationForm&quot; > <center> <font size=3> <br> <b> <logic:notEqual property=&quot;action&quot; name=&quot;ImageLocationForm&quot; value=&quot;Insert&quot;> <bean:message key=&quot;imagelocationdetail.title&quot;/> </logic:notEqual> <logic:equal property=&quot;action&quot; name=&quot;ImageLocationForm&quot; value=&quot;Insert&quot;> <bean:message key=&quot;imagelocationinsert.title&quot;/> </logic:equal> … …
  • 60.
  • 61.
  • 62. Custom Tags <%@ taglib uri=&quot;WEB-INF/imagebroker.tld&quot; prefix=&quot;broker&quot; %> <table width=750 cellspacing=0 cellpadding=2 border=2 > <tr> <td><broker:form lob='<%=test.getLob()%>' unitnbr='<%=test.getUnitnbr()%>' userid='<%=test.getUserid()%>' > <broker:doctype value=&quot;Invoice&quot;/> <broker:keyword name=&quot;CompanyNbr&quot; value=&quot;55555&quot;/> <broker:keyword name=&quot;PONbr&quot; value=&quot;M12345&quot;/> <broker:constraint name=&quot;FromDate&quot; value=&quot;02/02/2002&quot;/> <broker:constraint name=&quot;ToDate&quot; value=&quot;02/28/2002&quot;/> Image Broker Link Test </broker:form> </td> </tr> </table>
  • 63. Custom Tags – tld File <tag> <name>doctype</name> <tagclass>com.pri.brokertag.ImageBrokerDoctype</tagclass> <attribute> <name>value</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> </tag>
  • 64. Custom Tags – Tag Class public class ImageBrokerDoctype extends TagSupport { private String value = null; public int doStartTag() throws JspException { Hashtable ht = null; String keyword_count = null; int iCnt = 0; HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); ht = (Hashtable) request.getAttribute(&quot;keyword_parms&quot;); keyword_count = (String) request.getAttribute(&quot;queryobject_count&quot;); iCnt ++; ht.put(&quot;QueryObject&quot; + iCnt, value); request.setAttribute(&quot;keyword_parms&quot;, ht); request.setAttribute(&quot;queryobject_count&quot;, new String(new Integer(iCnt).toString())); return EVAL_PAGE; } }
  • 66.
  • 67.
  • 68. Struts-config.xml <?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?> <!DOCTYPE struts-config PUBLIC &quot;-//Apache Software Foundation//DTD Struts Configuration 1.0//EN&quot; &quot;http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd&quot;> <struts-config> <!-- ========== Form Bean Definitions =================================== --> <form-beans> <form-bean name=&quot;CryptForm&quot; type=&quot;com.pri.imagebrokerWeb.CryptForm&quot; /> </form-beans> <!-- ========== Global Forward Definitions ============================== --> <global-forwards> <forward name=&quot;start&quot; path=&quot;/index.html&quot;/> </global-forwards> <!-- ========== Action Mapping Definitions ============================== --> <action-mappings> <action path=&quot;/CryptForm&quot; type=&quot;com.pri.imagebrokerWeb.CryptAction&quot; name=&quot;CryptForm&quot; scope=&quot;request&quot; input=&quot;/pgCrypt.jsp&quot;> <forward name=&quot;encrypt&quot; path=&quot;/pgCryptDisplay.jsp&quot;/> </action> </action-mappings> </struts-config>
  • 70.
  • 71. Web.xml File <?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?> <!DOCTYPE web-app PUBLIC &quot;-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN&quot; &quot;http://java.sun.com/j2ee/dtds/web-app_2_2.dtd&quot;> <web-app id=&quot;WebApp&quot;> <display-name>imagebrokerWeb</display-name> <!-- Action Servlet Configuration --> <servlet id=&quot;Servlet_1&quot;> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>application</param-name><param-value>imagebrokerWeb</param-value> </init-param> <init-param> <param-name>config</param-name><param-value>WEB-INF/struts-config.xml</param-value> </init-param> </servlet>
  • 72. Web.xml File - continued <!-- Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- The Welcome File List --> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list>
  • 73. Web.xml File - continued <!-- Struts Tag Library Descriptors --> <taglib> <taglib-uri>WEB-INF/struts-bean.tld</taglib-uri> <taglib-location>/WEB-INF/struts-bean.tld</taglib-location> </taglib> <taglib> <taglib-uri>WEB-INF/struts-html.tld</taglib-uri> <taglib-location>/WEB-INF/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>WEB-INF/struts-logic.tld</taglib-uri> <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> </taglib> </web-app>
  • 75. Application.properties File error.cryptvalue.required=<li>You must enter some text.</li> error.lob.required=<li>You must enter the Line of Business.</li> error.unitnbr.required=<li>You must enter the Unit Number.</li> error.onbase_dns.required=<li>You must enter the OnBase DNS.</li> imagebroker.linkname=Project Refinery, Inc. imagebroker.title=pri Image Broker imagebrokerlink.title=pri Image Broker Link Test imagelocationlist.title=Image Location List imagelocationdetail.title=Image Location Detail imagelocationinsert.title=Image Location Insert errors.header= errors.footer=
  • 77.