In today's Web applications, friendly user input validations with obvious graphic alert images and warning messages have become standard. These input validation rules are defined based on business needs, which filter out any bad data input by users. This not only increases system stability, but also improves user experience. How can you add this type of validation to your Web application?

The popular Java Web MVC framework, Apache Struts, provides an ideal solution for validating form input. This article will show you how to use it through solving a practical validation scenario. You'll see two different implementation solutions: the first uses the traditional procedural programming method; the second demonstrates the object-oriented approach by way of Struts customized validation plug-in integration.

Hopefully, this comparison will show you how object-oriented design principles and design patterns-specifically, the strategy, factory, and singleton patterns, can be applied to Struts' customized form validation.