Procedure to Apply Validation Plugin based Validation Rules

Procedure to apply validator plug-in based validation rules (required rules on Struts application with respect to 1st App).

Step1: Configure validator plug-in Struts-config file

               In Struts-config.xml (After <location-mapping> tag).


               < Plug-in classname = “org.apache.Struts.validator.ValidatorForm”>

<set-property property = “pathname” value = “/WEB-INF/ validator-rules.xml, /WEB-INF/ validation.xml”/>


(Gather it form Struts/apps/apps folder supplied example App)

Step2:- Arrange validate-rules.xml file in WEB-INF folder of Struts App by extracting it form Struts-core-1.3.8.jar file

Step3:- prepares properties file in WEB-INF / classes folder having validator rules related default error.messages.

          [WEB-INF / classes / / Struts validator ErrorMessages]

                 Errors.requied = {0} is required

                 Errors.minlength = {0} cannot be less than {1} characters.

Note: – we can collect the above 14 default error messages form the comment of validator-rules.xml file.

Step4:- configure above properties file in Struts-config file.

              In Struts-config.xml file (after </action-mapping>)

                    <message-resources parameter = “myfile”/>

Step5:- make your form bean class extending form the predefined validator form class.


             Package app;

              Important org.apache.Struts.action.*;

              Important org.apache.Struts.validator.*;

             Public class RegisterForm extends validatorForm


                            Private string username;

                           Private string password;

                            Public RegisterForm ()


                                   S.O.pln (“RegisterForm (): o=param constructor”);


                         Public void set username………..



Complete the above form bean class javac – d.*.java

Step6:- Develop validation.xml file in WEB-INF folder configuring validator rules on form bean properties (required rule).

Note: – gather this file from Struts/apps/apps folder related example app & modify its needed.


                <!DOCTYPE     ————-    ltd>



                          <form name = “rf”>

                             <field properties = “username” depends = “required”>

                                 <arg position = “0” key = my.un“/>


             <field property = “password” depends = “required”>

                         <arg position + “0” key = “my.pass”/>





  • The “required” validator rule related default error msg is errors.required = {0} is repuired.

Step7:- Add user defined msg to properties file supplying argument {n} values of default error messages.

              In (take this ‘3’ lines)

                 # User defined msgs supplying {0} value for required rule error msg.

                       My.un = Login username

                       My.pass = login password

Step8: – Configure input page for action class to display form validation error-messages.

In Struts-config.xml:-


                 <action path = “register” type = “app.RegisterAction” name = “rf” input =





Step9:– Add <html: errors> in the input page to display positions

In Register.jsp:-




                 <html: errors1>

Step10:- Develop remaining resources of app like 1st App (Struts Demo App1)

  • While working with validator plug-in we can still four fixed keeps to apply styles on error messages.

           Errors.header = <font color = red size = 1>

          Errors.footer = ———–

          Errors.prefix = ———–

           Errors.suffix = ————–

While working with validation plug-in the form bean property name it self acts as form validation error logicalname when validations errors are generated on that form bean property in the above step based example App. to display form validation error-messages with respect to form component positions write following code in


             <% % ——— tag-html %>

              <html: form action = “register” method = “get”>

   Username: < html: text property= “username”/> < html: errors property= “username”/><br>

   Password: < html: property= “username”/> < html: errors property= “password”/><br>

         < html: submit value= “CheckDetails”/>

           </ html: form>

  • Form bean properties name adding as Logical name of form validation errors Generated by validator plug-in.


1)      Register.jsp–>replace inl—>form page, input page, result page

2)      Web.xml—> td file

3)      Validation.xmll—>td file to configure validator plug-in resated validation rules.




Leave a Reply

Your email address will not be published. Required fields are marked *