Você está na página 1de 6

Using Struts to Develop

J2EE Applications
Course No. 3492

Description This course introduces the developer to the Struts architecture and provides the basis for planning, developing,
and deploying Web based applications using the Struts framework. Upon completion of this class, the developer
will be able to quickly construct dynamic server-side web pages using Struts. It includes all the important concepts,
and hands on labs that will enable you to build working Struts.

Audience Experienced Java Developers who want to learn how to use J2EE components to build enterprise web applications.

Prerequisites Students should have six months prior Java development experience, including some experience using Server
Side technologies (Servlets/JSPs) Students should be comfortable creating a servlet and JSP. Or students can be
participating in our focused training curriculum.

Objectives Struts is an advanced Model-View-Controller (MVC) framework for building Servlet/JSP based web applications.
It is an open source framework built as part of the Jakarta project (the makers of Tomcat) that leverages the
capabilities of Servlets/JSP and custom tags to make it easier to use these technologies on large or complex web
systems.

Struts addresses many major issues in using vanilla Servlets/JSP to build web systems. It solves the problem of
controller complexity by removing the workflow logic from the servlets, and directing workflow in an XML
configuration file. Struts improves on the limited form support in JSP by adding numerous capabilities to form
processing including easy validation, easy error display, and the refilling of form input on form retries from a users
previous entries. It minimizes the complexity of JSP pages, by supplying a very extensive and flexible set of custom
tag libraries for many of the standard operations needed in JSP pages.

This course will get you up to speed with Struts in a very short time. It includes all the important concepts, and
hands on labs that will have you building working Struts applications in no time flat.

Working in a hands-on environment, students will learn to:


• Understand the problems with vanilla servlets/JSP, and the motivation for Struts
• Understand MVC and the Struts architecture
• Understand the Struts controller, Struts views, and Struts resource bundles
• Create & configure applications using Struts
• Define views, actions, and FormBeans
• Use Struts for form processing
• Use ActionMappings
• Handle errors and debug Struts applications
• Use the Bean, Logic, and HTML Custom Tag Libraries
©2007-08 | Keane, Inc.

• Use the flow-of-control custom tags

Australia | Canada | China | France | India | New Zealand | Singapore | Switzerland | UAE | UK | USA www.keane.com/education/
info@keane.com
Major Topics • Servlets/JSP Review
• Struts Architecture: Model View Controller
• Struts – Overview
• Configuration
• Struts Components: The Action Class
• ActionForms and FormBeans
• Struts Components: ActionForwards
• Struts Tags
• I18N and Struts
• DynaActionForms
• Struts Components: Validator
• Tiles

Duration 5 days

Australia | Canada | China | France | India | New Zealand | Singapore | Switzerland | UAE | UK | USA www.keane.com/education/
info@keane.com
Course Contents

1. Servlets/JSP Review • Servlet Creates JavaBean


• Objectives • JSP Uses JavaBean
• Overview – J2EE Web App • Summary
• Class Hierarchy 2. Struts Architecture: Model View Controller
• Requests and Responses • Objectives
• Returning Content From a Servlet • Separation of Concerns Principle
• Servlet Example • Application Partitioning
• Servlet Lifecycle • MVC Architecture Pattern
• Invoking a Servlet • MVC and MVC Model 2
• Web Applications • MVC in J2EE
• J2EE Containers • What is Struts?
• Servlet Bindings • What is a Framework?
• Sample web.xml File • View Layer in MVC
• Session Tracking Overview • View Elements in Struts
• Session Tracking API • Examples of View Elements
• Using HttpSession • Controller Layer in MVC
• Session Example • The Struts Controller
• Closing Connections • Other Controller Components
• Servlet Communication • Model Layer in MVC
• Redirection • Model Elements in Struts
• Redirection Example • Examples of Model Elements
• Request Dispatching • Command Pattern
• Forward Dispatching • Why Struts?
• Include Dispatching • Alternatives to Struts
• MVC • Summary
• JSP Review
3. Struts – Overview
• JSP Motivation
• Objectives
• JSP Example
• How Did Struts Get Here?
• Directives
• What is a Framework?
• Page Directive Example
• Basic Elements of Struts
• Scriptlets
• Struts Component Interactions
• Implicit Objects
• Struts Components and Classes
• Declarations
• Comparison of JSP and Struts Implementation
• Expressions
• Typical Struts Request/Response
• Comments
• User Request Flow Using Struts
• JSP Example
• ActionServlet
• Using Java Beans in JSPs
• web-xml
• What are JavaBeans?
• ActionMapping
• Architectural View
o Entry in struts-config.xml
• JSPs: The useBean Tag
o Action Tag Attributes
• Using the Bean – jsp:getProperty
• Action

Australia | Canada | China | France | India | New Zealand | Singapore | Switzerland | UAE | UK | USA www.keane.com/education/
info@keane.com
o Code Snippet 6. ActionForms and FormBeans
• ActionForm • Objectives
• ActionForward • ActionForms and FormBeans
• Global Forwards o Whats the difference?
• ActionError o Role – Data Carrier
• ActionMessage o Autopopulation
• ActionErrors o Simple Example
• Summary • Data types

4. Configuration • Lifecycle of FormBeans

• Objectives • ActionForms

• Java Web Apps o reset( )

• Configuring web.xml for Struts o What If reset() Is Not Defined for a Property?

• Example web.xml o reset() with Check Boxes

• struts-config.xml o validate( )

• Example struts-config.xml • ActionError

• Cache of struts-config.xml • ActionErrors

• Reloading config file • Sample validate( )

• Multiple config files • validate( ) Best Practices

• Multiple config files example • FormBean

• Other config files o Setting up FormBeans in struts-config.xml

• Struts Modules • Summary

• Summary 7. Struts Components: ActionForwards

5. Struts Components: The Action Class • Objectives

• Objectives • User Interface Navigation

• What are Actions? • What is an ActionForward?

• ActionServlet and RequestProcessor • The <forward> Entry in struts-config.xml

• The Action Class’s execute( ) method • <forward> Attributes

• Thread Safety in Actions • ActionForward in Action classes

• What Does execute( ) Do? • The ActionForward Class

• Avoid Business Logic in execute( ) • The ActionMapping Class

• How Errors Work • Forward vs. Redirect

• Errors in Response JSP • Return a null ActionForward

• Sample <action> Entry of struts-config.xml • Global vs. Action Forwards

• Attributes of the <action> Element • ActionForward Tips and Tricks

• Pre-defined Action classes • Summary

• Exceptions in an Action class


• Local Exceptions
• Global Exceptions
• How Actions are Accessed
• Actions “in action”
• Action Tips and Tricks
• Summary

Australia | Canada | China | France | India | New Zealand | Singapore | Switzerland | UAE | UK | USA www.keane.com/education/
info@keane.com
8. Struts Tags o formatKey Example
• Objectives • <html:tags>
• Tags in JSP • html img and image tags
• Struts custom tags • <html:errors> and <html:messages>
• Taglib directive • Summary
• Struts HTML tags 10. DynaActionForms
• Struts <html:form> tag • Objectives
• <html:text> and <html:password> • ActionForms - Reminder of Struts Data Container
• Struts <html:select> tag • Issue with ActionForms
• <html:options> • DynaActionForm to the Rescue
• <html:link> • What About reset()?
• <html:errors> • What about validate()?
• Struts Bean Tags • DynaActionForms
• <bean:define> o Recap Using
• <bean:cookie> o Recap configuring
• <bean:header> & <bean:parameter> • DynaActionForms Recap Using
• <bean:message>
11. Struts Components: Validator
o Arguments
• Objectives
• <bean:write>
• Validation Overview
• Struts Logic Tags
• Validation “Under the Hood”
• <logic:iterate>
• Components of Struts Validator
• <logic:match>
• Predefined Validators
• Other Logic Branching Tags
• Default Messages for Predefined Validators
• <logic:redirect>
• Using Validators in a Struts Application
• Summary
• Configuring the Validator Plugin
9. I18N and Struts • Creating the Form Class
• Objectives • Creating a Dynamic Validator Form Bean
• I18N • Defining Field Validation in validation.xml
• Localization • The <field> Element in validation.xml
• Elements to Consider • Enabling Client-Side Validation
• Java Support for Localization • Using Masks
• Locale Review • Field Validation Examples
• ResourceBundle Review • Final Steps in Validation
• Example Properties • Validator Tips and Tricks
• Word Order and Substitutions • Summary
• MessageFormat
• I18N and Struts
• Locale in Struts
• Cached Locale Object
• Configuring MessageResources
• Locale aware tags:
• <bean:message> tag
• <bean:write> tag

Australia | Canada | China | France | India | New Zealand | Singapore | Switzerland | UAE | UK | USA www.keane.com/education/
info@keane.com
12. Tiles
• Objectives
• Tiles Overview
• Tiles Example Website
• Implementing Tiles
• Putting it all together
• Steps to use Tiles
• Tiles Plug-in Overview
• Tile Definitions
o Overview
o Creating a Tile Definition in XML
o Example tile definitions
o Tile definitions via custom tags
o Example JSP using a layout
defined in “definitions.jsp”
• Layouts
o Overview
o Example
• Steps to use Tiles - Creating Content
JSPs (creating the Tiles)
• Use the Tiles Definitions
o Overview
o Inserting the Definition
o Passing a Value in a Body
• Extending Tile Definitions - “Inheritence” for Tiles
• Tile Scope Overview
• Tile Scope <tiles:useAttribute>
• Summary

Australia | Canada | China | France | India | New Zealand | Singapore | Switzerland | UAE | UK | USA www.keane.com/education/
info@keane.com

Você também pode gostar