One of the benefits of using Struts framework is declarative validation mechanism and error reporting. Struts provides validation hook so that you can implement your own validation logic in action classes. The validation can be turned on/off in action mapping using validate property.
In action class you can override validate() and it’s signature is:
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
Typically you validate presentation related information such as missing text or wrong format etc., If a validation error occurred for an input field, you can create an ActionError class with message key (for internationalization purposes ) and the name of the input field. In the JSP you can use Struts <html:errors /> tag to display these errors.
Sometimes you need to validate business validation such as ‘check user alredy existed in the system’, these should be performed in actions’ perform(), I will post the details in my next blog.