Free Sample
+ Collection

Apache Struts 2 Web Application Development

Dave Newton

A beginner’s guide for Java developers
RRP $20.99
RRP $34.99
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781847193391
Paperback384 pages

About This Book

  • Design, develop, test, and deploy your web applications using Struts 2 framework
  • No prior knowledge of JavaScript and CSS is required
  • Apply the best of agile development techniques and TDD techniques
  • Step-by-step instructions and careful explanations with lots of code examples

Who This Book Is For

This book is for Java developers who are interested in developing web applications using Struts. If you need a comprehensive introduction to Struts 2.1, along with the most important aspects of additional web application development technologies, agile programming practices, tool creation, and application life cycle management this book is for you. You don't need to know JavaScript and CSS to use this book as the author will teach you the required basics.

If you are a Struts 1 or WebWork user and wish to go ahead and migrate to Struts 2, this practical guide is also for you.

Table of Contents

Chapter 1: Struts and Agile Development
Struts 2 in a nutshell
Agile in a nutshell
Real applications in a nutshell
Getting started
Chapter 2: Basic Configuration
Setting up our environment
Getting started with our application
Chapter 3: Actions and ActionSupport
ActionSupport and its interfaces
Implementing our first user story
More action interfaces
Additional action interfaces
Chapter 4: Results and Result Types
The dispatcher result type
The redirect result type
The redirectAction result type
The chain result type (action chaining)
The parse parameter and a usecase detour
The FreeMarker and Velocity result types
The XSLT result type
The plaintext result
The stream result
The httpheader result
The Tiles and JasperReports results
Creating custom result types
Chapter 5: OGNL, the Value Stack, and Custom Tags
The <s:set> tag
Calling static methods from OGNL
Collections and iteration
Referencing other pages and actions
Chapter 6: Form Tags
Form tag basics
Chapter 7: Form Validation and Type Conversion
Form validation
Type conversion
Chapter 8: Interceptors
The basics
Interceptors in the default stack
Other important interceptors and interceptor stacks
Writing our own interceptors
Chapter 9: Exceptions and Logging
Handling exceptions in Struts 2
Chapter 10: Getting Started with JavaScript
Introduction to JavaScript
Minor syntax and language notes
Variables and scoping
Exception handling
Introduction to JavaScript objects and OOP
Introduction to JavaScript classes
JavaScript modules and OOP
Chapter 11: Advanced JavaScript, the DOM, and CSS
The importance of markup
Adding dynamic form elements
Chapter 12: Themes and Templates
Extracting the templates
A maze of twisty little passages
Other uses of templates
Chapter 13: Rich Internet Applications
What this chapter is and isn't
Dojo tags
The REST plug-in
Chapter 14: Comprehensive Testing
Test-driven development
Unit testing
Unit tests focus code intent
Testing Struts 2 in context
Client-side (functional) testing
Other forms of testing
Chapter 15: Documenting our Application
Documenting Java
Documenting web applications
Documenting development

What You Will Learn

  • Explore the features of Struts 2.1 to develop your application
  • Enhance your web application by writing your own custom result type
  • Create your own type converter to handle custom data types
  • Automatically generate application and development documentation
  • Learn good exception handling practices for your applications
  • Implement rich client behavior using JavaScript, the DOM, and CSS
  • Create custom themes and templates to make shorter, cleaner JSP pages
  • Run many types of tests both to prove functionality and to make change safe

In Detail

Struts 2.1 is a modern, extensible, agile web application framework suitable for both small- and large-scale web applications.

The book begins with a comprehensive look at Struts 2.1 basics, interspersed with detours into more advanced development topics. You'll learn about configuring Struts 2.1 actions, results, and interceptors via both XML and Java annotations. You'll get an introduction to most of the Struts 2.1 custom tags and learn how they can assist in rapid application prototyping and development.

From there you'll make your way into Struts 2.1's strong support for form validation and type conversion, which allows you to treat your form values as domain objects without cluttering your code. A look at Struts 2.1's interceptors is the final piece of the Struts 2.1 puzzle, allowing you to leverage the standard Struts 2 interceptors as well as implement your own custom behavior.

After covering Struts 2.1 you'll journey into the world of JavaScript, a surprisingly capable language, the Document Object Model (DOM), and CSS, and learn how to create clean and concise client-side behavior. You'll leverage that knowledge as you move on to Struts 2 themes and templates, which give you a powerful way to encapsulate site-wide user interface behavior.

The book closes with a look at some tools that make the application development life cycle easier to manage, particularly in a team environment, and more automatic.


Read More