Server Side Programmatic Form Validation – Struts Tutorial

Procedure to perform server side programmatic form validation with respect to our first Struts application:-

Note: – For the above requirement we need to write the java code based form validation logic by overriding the validation () in our form bean class.

Step1:- Prepare properties file having form validation error messages. :-

     # user-defined form validation error message

    My.un.req.err = Logic username is required

    My.pass.req.err = Logic password is required

    My.un.alpha.err = Logic username must being with an alphatbet

    My.pass.alpha.err = Logic password must being with an alphatbet

Note: – in the above file keys & values are user defined

Step2:- configure properties file in Struts-configuration file

In Struts-configuration.xml:-   

Step3:- override validate () method in form bean class as shown below.






Step4:- configure input jsp page for Struts action class (RegisterAction class)

The jsp page using which the form validation errors will be displayed.

Step5:- Add html errors tag in the input jsp program to decide the position of displaying from validation error messages.


Step5:- Develop the remaining resource of Struts application like our first application.

Leave a Reply

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