how to implement singletun design patteren in struts?
Answer Posted / sk neelofar
public class Sample
{
pubic static Sample s=new Sample();
private sample(){
}//constructor
public static smple getInstance()//static factory method
{
return s;
}//method
}//class
......
Sample s1= Sample.getInstance();
Sample s2= Sample.getInstance();
1.A static method can b called outside the class using clas
name.
2.In this implementation, we used private constructor n a
static factory method to make a class as a singleton class.
3.if we call the getInstance(); of the class for any no. of
times, same object of the class will b returned to the
programmer.
4. the programmer can't create an object pf this class
outside the class, coz it has a private constructor.
| Is This Answer Correct ? | 23 Yes | 2 No |
Post New Answer View All Answers
How can we get Servlet API Request, Response, HttpSession etc Objects in action classes?
What is the purpose of @requiredstringvalidator?
When it’s useful to use IncludeAction?
Where can I get a copy of struts?
What is package name in struts xml?
In how many ways duplicate form submission can occurs?
What is the purpose of @element?
Explain about token feature in struts?
What are the different kinds of actions in struts?
Explain struts.devmode?
How you will make available any message resources definitions file to the struts framework environment?
Explain about the process of functioning of the struts program?
Can you give an overview of how a struts application flows?
Explain about the
What is the purpose of @typeconversion annotation annotation?