how to implement singletun design patteren in struts?

Answer Posted / shaik baji

Singletun design patteren means we can't create more than
one object for that class which follws Singletun design
pattern.

We can implement it by using one "private" constructor and
one Factory mathod as like follows:

class Sample
{
public static Sample s = new Sample();

private Sample()//constructor
{

}
public static Sample getInstance()//static factory
method
{
return s;
}
}

public class SingleTun
{
public static void main(String arg[])
{
Sample s1= Sample.getInstance();
Sample s2= Sample.getInstance();

}

}

Is This Answer Correct ?    5 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How you will display validation fail errors on jsp page?

546


What does params interceptor?

535


What is the naming convention for a resource bundle file in struts2?

541


How to convert struts to spring mvc?

539


How we can configured action mapping in struts?

583






What configuration changes are required to use resource files in Struts?

573


What are the reasons for an error message not being displayed while developing struts application?

547


What is difference between actionform and dynaactionform?

597


What are different Struts2 tags? How can we use them?

576


How interceptor works in struts 2?

596


What are the core classes of the struts framework?

517


What is http redirect?

571


How tag libraries are defined in Struts?

576


What is the use of namespace in action mapping in Struts2?

578


What is struts and why it is used?

505