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.

4.2. Design Patterns
Design patterns are the best practices to use software technologies in application development.
Design Patterns:

1.Singleton java class:
Java class that allows to create only one object per JVM is called Singleton java class.
- Instead of creating multiple objects of a java class having same data. It is recommended to create one object per JVM and using for multiple number of times. This process reduces memory wastage.
- In MVC architecture based application there must be only one servlet class object acting as Controller. So ActionServlet which is built in ControllerServlet of struts based web applications is given as Singleton java class.
- Every servlet is a single instance multiple threads components.That means when multiple requests are given to servlet class only one object of Servlet class will be created and multiple threads will be started on that object representing multiple requests.
A: ActionServlet is a built in servlet given by struts Framework spftware as singleton java class.
- Some web containers of webservers/application servers are violating servlet api-specification principles by creating multiple objects for servlet class in some special situations.
When struts application is deployed in these special servers in order to see only one object of ActionServlet is given as singleton java class.
A Servlet is identified through its url-pattern. We can use one of the three approaches to provide url-pattern for a Servlet.
1.Exact match:
other matchings:<url-pattern>/first</url-pattern>
<url-pattern>/first.xyz</url-pattern>
Example url : (valid)
- http://localhost:8080/wa1/first/xyz
- http://localhost:8080/wa1/xyz/first
- http://localhost:8080/wa1/xyz
- http://localhost:8080/wa1/first
- http://localhost:8080/wa1/abc
- http://localhost:8080/wa1/first/xyz/abc
2.Direct match:

- Direct match url pattern ends with * symbol.
- url-pattern is to provide the secrecy to servlet by hiding their names.
http://localhost:8080/wa1/x/y/abc
http://localhost:8080/wa1/x/y/z/abc
http://localhost:8080/wa1/x/y/
http://localhost:8080/x/y/xyz/a/b/abc
Example urls(invalid):
http://localhost:8080/wa1/y/x
http://localhost:8080/wa1/a/b/x/y/abc
3.Extension match:
Extension match url-pattern starts with '*' symbol.Example urls (valid) :
http://localhost:8080/wa1/x/y/z.cpp
http://localhost:8080/wa1/x/y.cpp
http://localhost:8080/wa1/.cpp
Example urls (invalid) :
http://localhost:8080/wa1/a/b/c.cpp/x/y
http://localhost:8080/wa1/x/c.abc
Any extension will be given but it has to match the given URL pattern extension.
We can't frame URL-pattern by mixing up extension match and directly match.Because the underlying web server does not recognize this kind of URL-pattern . Because it is against servlet specification.
