Preface

It's been almost 10 years since I developed my first web-based application. The program was a simple online shopping cart written in Perl. I still have the code lying around, and I look at it occasionally - I do this to remind myself of where I was and to keep myself focused on where I want to go. The application was horrible. It consisted of one extremely large Perl file (over 10,000 lines!), and it printed out HTML using lots of print statements. Looking at it today, it's impossible for me to understand.

And yet, 10 years ago, I managed to put together something that not only was functional but also made sense to me. This growth is typical of what most professional developers go through, Jason and me included. The "hacks" I wrote made sense at the time, but as the months and years went on, the code became a rat's nest and maintenance was a nightmare. This problem is bad enough when you're developing non-GUI programs, but it's worse when bad code that handles business logic is mixed with bad code that handles the GUI. And it's even worse when your GUI is written in HTML, and you're relying on linearly spitting out HTML tags instead of using object orientation or componentization.

Why is this important? Because, like all other developers, Jason and I have grown from novice programmers hacking in Perl and PHP (and not really knowing what we were doing) to experienced developers with a deep understanding of what it takes to build a maintainable web-based application.

Jason and I didn't create WebWork. It was developed by Rickard ?berg, one of the original authors of JBoss, after he decided there had to be a better way to develop web applications. What came from Rickard was a framework built around the philosophy that the correct way to do something should also be the easiest option, that the path of least resistance is a good thing, and that there is a fine balance between too much flexibility and too little.

Jason and I found WebWork through different means, but the end result was the same: We were captivated by its functionality and grace. Over time, we evolved from users to contributors to developers, and now to published authors. In the process, we've learned better ways to do things. And similarly, WebWork has also evolved. Jason and I spent endless nights creating version 2.0, which has become a major upgrade and has set the groundwork for doing much more with the WebWork platform.

Today, WebWork is much more than it was in the past. And tomorrow, it will be even better. In this book, you'll learn the techniques, best practices, and concepts that go with the WebWork framework. You'll see why we spent so much energy on type conversion and how it relates to HTTP. You'll learn about how common challenges in the world of HTML (such as the double-submit problem) were solved using interceptors - a feature unique to WebWork. You'll understand why building reusable templates that generate HTML is the best way to quickly create maintainable web applications.

Mostly, though, you'll learn a better way to build web applications. Whether you're already a WebWork user, or you use an alternative Java framework, or you don't use Java at all, this book provides the concepts and techniques that are the foundation of WebWork. We hope this book serves as a WebWork reference and also as a great tool for sharpening your development skills.

Patrick Lightbody