The Struts Framework – 4 Days
The Struts Framework training course This advanced course shows JSP and servlet programmers how to build web applications using the Apache Struts framework. Students learn the Struts architecture and see how it captures a great deal of pre-existing best practice: in model/view/controller action mappings, form beans and custom tags for working with HTML forms, input validation, and the Tiles view-building framework. Two chapters near the end of the course cover configuration techniques and other advanced topics.
This version of the course illustrates the use of Struts 1.3
What You Will Learn
- Use Struts actions and action mappings to take control of HTTP requests/responses.
- Manage HTML form input and output with form beans, and use these beans to simplify data handling in the controller.
- Use JSTL and Struts custom tags to build robust and reusable JSP presentation logic.
- Support multiple client locales with various internationalization techniques.
- Define validation rules for input forms, and provide clear user feedback.
- Build complex presentations using decoupled, reusable tiles, screens and layouts.
- Java programming is excellent preparation.
- Basic knowledge of XML is recommended but not essential. Intro to XML.
- Servlets programming
Chapter 1. Struts Architecture
- MVC and Model 2
- Command Pattern
- Jakarta Struts
- More XML, Less Java!
- Action Mappings
- JavaBeans in Struts
- Working with Forms
- Presentation Technology
Chapter 2. Action Mappings
- Command Pattern for Web Applications
- Action and Action Mappings
- Struts Configuration
- Selecting a Forward
- Global Forwards
- Declarative Exception Handling
- Global Exception Handlers
Chapter 3. Forms
- Working with HTML Forms
- Action Forms, a/k/a Form Beans
- Relationship to Input
- Relationship to Actions
- Relationship to the Model
- Relationship to Output
- DynaActionForm and Map-Backed Forms
- Coarse-Grained Form Beans
Chapter 4. Struts Tag Libraries
- Building View Components
- Struts Tag Libraries
- Attributes and Struts Expressions
- Building Forms
- <html:text> et. al.
- Forms and Form Beans
- Scope and Duration of Form Data
- Managing Hyperlinks
- Error Messages
- Logic Tags
Chapter 5. The JSP Standard Tag Library
- JSTL Overview
- JSP Expression Language
- Core Tags
- Formatting Tags
- SQL Tags
- XML Tags
- Mixing JSTL, EL, Scripts and Actions
- Indexed Properties and Struts HTML Forms
Chapter 6. Internationalization and Localization
- i18n in Java
- i18n in Actions
- i18n in JSTL
- i18n in Validation
Chapter 7. Input Validation
- Validation in Web Applications
- Validation in Struts
- The Struts Validator Plug-In
- Validating ActionForm Subtypes
- Configuring Validation
- Standard Validators
- The ActionMessages Class
- Is <html:form> Necessary?
- Reporting Errors
- Multi-Page Validation
- Client-Side Validation
- Limitations on the Client Side
- Implementing a Validator
- Implementing ActionForm.validate
- Mapping-Based Validation
Chapter 8. Advanced Configuration
- Struts Configuration in Depth
- The Configuration Object Model
- Subclasses and <set-property>
- Integrating Other Frameworks
- Role-Based Security
- Chaining Actions
- The ComposableRequestProcessor Class
- Configuring Command Chains
Chapter 9. Under the Hood
- Global Objects
- Specialized Struts Actions
- The Utility Package
- The Commons BeanUtils Class
- Form Beans as Adapters to the Business Tier
- Reusing Validation Rules
- Graceful Validation
Chapter 10. Tiles
- Consistent Look and Feel
- Reusable Layouts and Content
- The Tiles Framework
- Instantiating Layouts
- Body-Wrap Insertions
- Tiles and Stylesheets
- Working with Tiles Attributes
- The Tiles Context
- Aggregation and Inheritance
- The Tiles Plug-In
- Forwarding to Definitions
- Performance Considerations
Appendix A. Learning Resources
Appendix B. Quick Reference
IDE Support: Eclipse WTP 2.0
- In addition to the primary lab files, an optional overlay is available that adds support for Eclipse WTP 2.0. Students can code, build, deploy, and test all exercises from within Eclipse, and take advantage of WTP’s built-in editors, integrated debugging, and wizards for web applications, XML files, JSPs, and more.
|Hardware Requirements (Minimum)||1.0 GHz, 500 meg RAM, 500 meg disk space.|
|Hardware Requirements (Recommended)||1.5 GHz, 1 gig RAM, 1 gig disk space.|
|Operating System||Tested on Windows XP Professional. Course software should be viable on all systems which support a J2SE 5.0 JDK.|
|Network and Security||Limited privileges required|
|Software Requirements||All free downloadable tools.|
Other Courses to Explore
Don’t forget to check out our monthly specials to save – Monthly Specials
What is The Struts Framework? From Wikipedia:
Apache Struts 1 is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model–view–controller (MVC) architecture. It was originally created by Craig McClanahan and donated to the Apache Foundation in May 2000. Formerly located under the Apache Jakarta Project and known as Jakarta Struts, it became a top-level Apache project in 2005.
The WebWork framework spun off from Apache Struts aiming to offer enhancements and refinements while retaining the same general architecture of the original Struts framework. However, it was announced in December 2005 that Struts would re-merge with WebWork. WebWork 2.2 has been adopted as Apache Struts 2, which reached its first full release in February 2007.
In a standard Java EE web application, the client will typically call to the server via a web form. The information is then either handed over to a Java Servlet which interacts with a database and produces an HTML-formatted response, or it is given to a JavaServer Pages (JSP) document that intermingles HTML and Java code to achieve the same result. Both approaches are often considered inadequate for large projects because they mix application logic with presentation and make maintenance difficult.
The goal of Struts is to separate the model (application logic that interacts with a database) from the view (HTML pages presented to the client) and the controller (instance that passes information between view and model). Struts provides the controller (a servlet known as
ActionServlet) and facilitates the writing of templates for the view or presentation layer (typically in JSP, but XML/XSLT and Velocity are also supported). The web application programmer is responsible for writing the model code, and for creating a central configuration file
struts-config.xml that binds together model, view, and controller.
Requests from the client are sent to the controller in the form of “Actions” defined in the configuration file; if the controller receives such a request it calls the corresponding Action class that interacts with the application-specific model code. The model code returns an “ActionForward”, a string telling the controller what output page to send to the client. Information is passed between model and view in the form of special JavaBeans. A powerful custom tag library allows it from the presentation layer to read and write the content of these beans without the need for any embedded Java code.
Struts also supports internationalization by web forms, and includes a template mechanism called “Tiles” that (for instance) allows the presentation layer to be composed from independent header, footer, menu navigation and content components.