Search code examples
validationstruts2server-sideconcept

Isn't validation process working on the server-side in Struts 2?


I get confused with the concept of validation in Struts. ActionSupport class provides the validation() method

public void validate(){}

which is used to validate the form. But isn't this process working on the server- side?

If it is then, is it fails the concept of validation?


Solution

  • The question isn't clear.

    Yes, an action's validate() method obviously validates on the server side.

    This is a Good Thing, because data must be validated on the server side, regardless of whether or not any client-side validation occurs. Consider (a) users that have JavaScript disabled, and (b) hand-crafted requests not made through a browser. While (a) is increasingly uncommon, (b) is a legitimate danger.

    You cannot rely on JS-only validation.