The class org.apache.struts.action.ActionServlet is the called the ActionServlet, this class plays the role of controller. All the requests to the server goes through the controller. Controller is responsible for handling all the requests.
The Action class is part of the controller. The purpose of Action Class is to translate the HttpServletRequest to the business logic. The ActionServlet passes the parameterized class to Action Form using the execute() method
Ex:
public class MyAction extends Action
{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
return mapping.findForward("myAction");
}
}
An ActionForm is a JavaBean that extends org.apache.struts.action.ActionForm. ActionForm maintains the session state for web application
and the ActionForm object is automatically populated on the server side
with data entered from a form on the client side
Ex:
public class MyForm extends ActionForm {
{
//inherited methods
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;
}
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
}
}
Struts Validator Framework
Struts Framework provides the functionality to validate the form data.t can be use to validate the data on the users browser as well as on the server side.Struts Framework generates the java scripts and it can be used to validate the form data on the client browser. Server side validation of form can be accomplished by sub classing your From Bean with DynaValidatorForm class
The Validator Framework uses two XML configuration files validator-rules.xml and validation.xml
the <html:javascript> tag is used to allow front-end validation based on the xml in validation.xml.