164 Java Interview Questions by Nageswara Rao
4.6.Example on FormBean Class
package p1;
public class RegisterForm extends org.apache.struts.action.ActionForm
{
String uname,pwd; //FormBean properties
public void setUname(String un)
{
uname = un;
}
public string getName()
{
return uname;
}
public void setPwd(String pass)
{
pwd=pass;
}
public String getPwd()
{
return pwd;
}
}
4.5.Struts configuration file
- Reading entries of web.xml is the responsibility of under laying web server or application server, application servers are using sax api, sax parser to read and process web.xml file.
- Struts framework software uses SAX parser, SAX api to read and process struts configuration file.
- Any "filename.xml" can become struts configuration file but it must be specified as input value to ActionServlet by using its init parameter 'config'.
4.4. Value Objects/Data transfer object class.
In order to send multiple values from one layer to another layer, it is recommended to combine multiple values into single object and send that object ot destination layer. It is not recommended to send multiple values between two layers foe multiple number of times. The class whose object combines multiple values into single object is called ValueObject class or DataTransferOject class.
- The implementation of this design pattern reduces round trips between two layers and it also makes easy to receive values only for one time in the destination layer.
- In struts application FormBean class acts as ValueObject class or DataTransgerObject class. Because multiple values given by form(data means form data) or stored into single object called FormBean class object and this FormBean class object is implicitly visible in the action class execute(). The business logic of execute() uses form data as input values by reading them form FormBean class object.
- In struts applications Form data of the view layer is visible Action class of modellayer. In the form of FormBean class object.
How ActionServlet acting as a FrontController.in Struts
Servlet acting as a Front-controller , then it is called Front-controller servlet. If JSP is acting as Front-controller then it is called Front-controller JSP.


