Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Struts Design Problem  RSS feed

 
Anirban dutta
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,
I have to design a Struts application. In this I have to do 2 types of validations(for a login form):
1) To check whether a field is empty or not.
2) To check whether the user and password match or not.
Now, as far as I understand Struts, for the first type of validation I should use "validate" method of the ActionForm, and, for the second type of the validation, I should use the "execute" method and redirect the user to a different JSP page if the login is invalid.
Now using "validate" method is a server-side validation and the validations inside a "execute" method is also a server-side validation. So if I validate the username and the password in the "validate" method, is it right? If not what difference will it make in case of implementation as well as design. Please clear the difference between validating in a ActionForm and in a Action class. I am very confused in it.
Thanks in Advance
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The form's validate is meant for basic validation like if the fields were left blank or if two password fields match each other.
The execute of the action (if it contains any validation at all) should be more business oriented validation, such as if the username and password matched or that a credit card passed authentication. The logic for these types of validation should be delegated to other objects anyway.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!