• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

multiple instances

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
S Sravs
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 598
3
jQuery Google App Engine Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sure, To end your curiosity write some short programs.

best regards,
omi
 
winay Kumar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic