Tutorials : Stepping through the Struts 1.1 Validator :

Step 2: Edit struts-config.xml

This file contains a lot of comments and elements which we don't need. I've edited it to look like this:

Listing 1. struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>

<!-- ======================================== Form Bean Definitions -->
<form-beans>
</form-beans>

<!-- =================================== Global Forward Definitions -->
<global-forwards>
  <!-- Default forward to "Welcome" action -->
  <!-- Demonstrates using index.jsp to forward -->
  <forward name="welcome" path="/Welcome.do"/>
</global-forwards>

<!-- =================================== Action Mapping Definitions -->
<action-mappings>
<!-- Default "Welcome" action -->
<!-- Forwards to Welcome.jsp -->
  <action path="/Welcome" 
    type="org.apache.struts.actions.ForwardAction"
    parameter="/pages/Welcome.jsp"/>
</action-mappings>

<!-- ================================ Message Resources Definitions -->
<message-resources parameter="resources.application"/>

<!-- ======================================= Plug Ins Configuration -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
  <set-property property="pathnames"
    value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>

</struts-config>

The global-forwards and action-mappings section serves the welcome page, which is the only page in the struts-blank application.

Note the message-resources section, which points to the message resource file. It's found in classes/resources and is called application.properties.

Finally we find the first trace of the new Validator. The Validator is a "plug-in", which must be defined as above. The predefined validators are located in /WEB- INF/validator-rules.xml and the specific rules that apply to the application's HTML forms are located in /WEB- INF/validation.xml.  Since struts-blank doesn't use the Validator you'll only find some sample definitions in validation.xml

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.