aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes multiple instances Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "multiple instances" Watch "multiple instances" New topic
Author

multiple instances

S Sravs
Ranch Hand

Joined: Feb 25, 2008
Posts: 85
In HFSJ 1.4
pg no.183 Dumb Question
Dog is a Customer class,with each active instance representing a single suctomer's info for name,address,orfer info,etc

pg no.202 last Dumb Question
Stop rught there! you say "multiple instances fo the servlet".We know there is always only ONE instance of the servlet.One instance,many threads.

If servlet dont have multiple instances then how does Dog class can have multiple instances

thanks inadvance
Sravanthi
winay Kumar
Ranch Hand

Joined: Aug 13, 2007
Posts: 34
Hi,

Servlets wil have only one instance and multiple threads for each request. But this Dog class in not a servlet class. its like having multiple session objects for each active clients.


Winay Kumar<br />SCJP 5.0
S Sravs
Ranch Hand

Joined: Feb 25, 2008
Posts: 85
if that is the case then listener class too have multiple instances
container at first request set the listener class then for every request listener "instances" are created
is that correct
omi sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 489
sure, To end your curiosity write some short programs.

best regards,
omi


SCJP, OCA 9i application developer, SCWCD 5.
When I was in hell someone told me to get heaven you need to do Java.
winay Kumar
Ranch Hand

Joined: Aug 13, 2007
Posts: 34
Hi,

for the objects which you want to monitor when its added to session or when its removed from session for those classes only we will implement HttpSessionBindingListener inteface.

for example if you want to add Name, Address to session usually we will create String Variables right? In that case we cannot use HttpSessionBindingListener inteface. in that case we will create a class which implements HttpSessionBindingListener inteface. In that class we will declare String variable like String name, setter and getter methods for that variable and we will define interface methods valueUnbound, valueBound.

the author is telling like if we want to monitor name, address and info etc.. we will have to create a class for each thing. obviously we will have
multiple instance for each class for each session.
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
No, I would say this is not true.

The container will create an instance of the listener class to receive events and this instance could handle multiple threads just like servlets.


Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Garlapati Ravi
Ranch Hand

Joined: Mar 05, 2008
Posts: 168
how can we know, whether there are multiple objects or threads created for a Servlet ? only through books ?
or do we have any API methods or class to code ?

to now number of threads we can create a instance variable and increment it in class constructor, how about threads ? how to know the number of threads created for servlet ?


Ravi Kumar
SCWCD 5 - 89%, SCJP 1.4 - 90%
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: multiple instances
 
Similar Threads
Servlet Multiple instances?
multiple instances of same servlet class in WebLogic ?
Class loading.
init()
Single Inheritance vs. Multiple Inheritance