how to implement singletun design patteren in struts?

Answers were Sorted based on User's Feedback



how to implement singletun design patteren in struts?..

Answer / 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

how to implement singletun design patteren in struts?..

Answer / haneef

Hi guys..he is asking how to implement singleton in struts.

see if your using ActionServlet means, then we will
automatically uses singleton.

because, only one ActionServlet provides services to all the
customers.

Is This Answer Correct ?    19 Yes 0 No

how to implement singletun design patteren in struts?..

Answer / guest

Just we develop a class, in that we write a private
constructor. in that we define one method that returns the
object.

Is This Answer Correct ?    4 Yes 2 No

how to implement singletun design patteren in struts?..

Answer / 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

how to implement singletun design patteren in struts?..

Answer / sudheer

Struts are followed purely MVC1 Design pattern here
business logic is different from data presentation and
controller so struts are implemented singletun design pattern.

Is This Answer Correct ?    5 Yes 35 No

Post New Answer

More Struts Interview Questions

What is the purpose of '@keyproperty'?

0 Answers  


How to build struts application in eclipse?

0 Answers  


What is actionform in struts?

0 Answers  


i have a log in web application .... i want restrict the user for particular no of users what is procedure to develop thus application

2 Answers  


What are the important methods of actionform?

0 Answers  






In ActionClass we can use only one action i.e execute(), but in DispatchAction we can use multiple actions.My question is , we can use multiple actions in Action class if(action.equals("add") if(action.equals("update"). Then when to use Action and DispatchAction which is frequently in webapplications.

2 Answers  


Are interceptors thread safe?

0 Answers  


Explain the difference between plain-validator and field-validator in struts?

0 Answers  


What is the purpose of @key?

0 Answers  


What is action servlet in struts?

0 Answers  


what is the purpose of load_on_startup entry in struts- config.xml?

8 Answers   Satyam,


How can forward action be used to restrict a strut application to mvc?

0 Answers  


Categories