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
posted
0
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
posted
0
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
posted
0
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
posted
0
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
posted
0
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.
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 ?