Skip to main content

developerWorks  >  Java technology   >  

Using the Struts Validator

developerWorks

Level: Intermediate

Brett McLaughlin (brett@oreilly.com), Author and editor, O'Reilly and Associates

16 Aug 2005

Follow along as Web development expert Brett McLaughlin guides you through the process of installing and configuring the Struts Validator component. The Validator, originally developed separately from and on top of Struts, is now an integral component of any professional Struts application programming.With the Validator, you can validate input in your Struts ActionForms. In this tutorial, you will learn to perform this validation declaratively, without touching your existing Java code.

Register now or sign in using your IBM ID and password.

In this tutorial

This tutorial covers the following main sections:

  • Section 1: Before you start
  • Section 2: Building bulletproof applications with validation
  • Section 3: Setting up a sample application
  • Section 4: Installing the Validator framework
  • Section 5: Using the Validator in an application
  • Section 6: Working with the Validator
  • Section 7: Summary
  • Section 8: Appendix: Installing Struts on Tomcat 5.5.x


Prerequisites

  • This tutorial is written for Web developers who have some familiarity with Java technology, the Tomcat servlet engine, and the Struts application framework.
  • If you're using a servlet engine other than Tomcat, you will need to be comfortable with your servlet engine's setup and configuration. This tutorial assumes you're using Tomcat, and no extra detail is provided for non-Tomcat configurations. Check the Struts documentation for more information on installing Struts on servlet containers other than Tomcat.
  • This tutorial deals specifically with configuring Struts, so you'll need to be at least passingly familiar with XML documents. You should also have administrative access to the machine you have Struts set up on. We'll be adding some JAR files and changing the core Struts setup to get the Validator up and running. You also might want to brush up on declarative programming if declarative programming is new to you).

System requirements

  • You will need a machine -- or ISP -- that has a servlet engine, such as Apache Tomcat, installed. I highly recommend that you run through this tutorial either locally, on a development machine, or on a non-production ISP account. In other words, don't try this out on a machine serving thousands of users, as you're going to have to make changes to your servlet container and you may have to restart that container several times.
  • Although neither is required for this tutorial, I'm using version 5.0 of the Java platform on Mac OS X. Some of the warnings and output captures you'll see in this tutorial reflect that. Additionally, I'm using Tomcat 5.5.9, which requires version 5.0 of the Java platform (unless you download a special bit of code that allows it to work with earlier JVMs). There is no special version of the Java platform or Tomcat required for this tutorial, although I strongly urge you to use at least version 5.0.
  • You also need a good text editor (or XML and Java editor, if you prefer), preferably one where you can have several windows open at once.
  • Make sure you've downloaded the Struts engine and sample application.

Duration

Under one hour


Formats

HTML



Back to top


Document options

Document options requiring JavaScript are not displayed