Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


is it possible to create single instance of java class per
session in web application

Answers were Sorted based on User's Feedback



is it possible to create single instance of java class per session in web application..

Answer / savar33

Hi guys

the singleton solution will not work, since several nodes
are possible in the cluster, each node has it's own java.
Those singleton can be instanciated in each class.

Beside this the presented implementation of singleton design
pattern is improper. You should override constructor in this
way :
private Singleton(){};

I also would make getInstance() method synchronized. This is
multithreaded environment.

Is This Answer Correct ?    6 Yes 0 No

is it possible to create single instance of java class per session in web application..

Answer / ananth

by using Singleton pattern we can achieve one instance per
class.

Public final class Singleton{

private static Singleton singleton;

public static Singleton getInstance()
{
if(singleton ==null)
{
singleton=new Singleton();
}
retuen singleton;
}

public void getvalue()
{

}

}

Is This Answer Correct ?    7 Yes 6 No

is it possible to create single instance of java class per session in web application..

Answer / nirmal

The easiest way is to use RMI to start the app and check to
see if it's already running.

The basic structure is this:

The main method of your app checks the RMI registry to see
if the app is started. If so, exit.
Otherwise, the main creates an instance of the app (which
is a remote object) and registers it in the RMI registry.
The class' constructor creates the GUI and displays it.
Alternatively, you could create a "start" method that you
call via RMI to start the app.

Is This Answer Correct ?    0 Yes 2 No

is it possible to create single instance of java class per session in web application..

Answer / sk.bilal ahmed

yes
eg.,
Public final class Singleton{

private static Singleton singleton;

public static Singleton getInstance()
{
if(singleton ==null)
{
singleton=new Singleton();
}
retuen singleton;
}

public void getvalue()
{

}

}

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More J2EE Interview Questions

What is entity reference?

0 Answers  


What is java technology stack?

0 Answers  


How do you make a class immutable in java?

0 Answers  


What is jaap?

0 Answers  


What is java developer job description?

0 Answers  


Which one should we prefer while using bean ? managed bean annotation or faces-config

1 Answers  


Is j2ee and jee same?

0 Answers  


Who generates bytecode in java?

0 Answers  


What every java developer should know?

0 Answers  


What is instance in java?

0 Answers  


What is the use of method save()?

0 Answers  


how many external variables are there in jsp ?

1 Answers  


Categories