wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes how many instances??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "how many instances???" Watch "how many instances???" New topic
Author

how many instances???

Swati Kadam
Ranch Hand

Joined: Mar 05, 2008
Posts: 39
how many objects are created when same or different client send 100 requests to a servlet?


SCJP / Preparing For SCWCD
sammeta Phanikumar
Ranch Hand

Joined: Oct 25, 2007
Posts: 81
Only one instance(object) is created for one servlet and for each request for this servlet a seperate thread will be created.


SCJP 5, SCWCD 5, SCDJWS 5
Vishal Matere
Ranch Hand

Joined: Jan 22, 2008
Posts: 81
same client, 100 requests: 1 Instance (including SingleThreadedModel servlet)
Diff Client, 100 request: 100 instances (SingleThrededModel servlet)
Diff Client, 100 request: 1 instances (Normal Servlet)

HTH


SCJP <br />SCWCD <br />SCBCD <br />SCEA-1
pradeep singh
Ranch Hand

Joined: Oct 23, 2007
Posts: 339
Hi

same client, 100 requests: 1 Instance (including SingleThreadedModel servlet)


Why not 100 instances for 100 requests?


SCJP 5.0(75%), SCWCD 5.0(88%)
anil pamidi
Greenhorn

Joined: Apr 09, 2008
Posts: 15
Hi Vishal even I have the same doubt as Pradeep.

quote:
--------------------------------------------------------------------------------
same client, 100 requests: 1 Instance (including SingleThreadedModel servlet)
--------------------------------------------------------------------------------
why not 100 instances in the case of SingleThreadModel?


The only thing CONSTANT in life is CHANGE.
SCJP 1.4, Preparing for SCWCD 5
Atul Sawant
Ranch Hand

Joined: Jul 06, 2006
Posts: 304
Everytime you send a request it is a new request for the server because HTTP communication is stateless. So, it does not matter if it is a same client or different client. Every request is treated as unique and different.

If you apply singleThreadModel, the instance of that servlet is giving to only one thread (request) at a time. it is NOT creating 100 instances for 100 requests. The instance will be only one, but it will be accessed by one thread (request) at a time.


Mission SCWCD. Mission SCJP Complete: SCJP 1.4 - 91%
vishal_kumar
Greenhorn

Joined: Apr 27, 2008
Posts: 2
Hi

i would like to add one thing with single thread model, it is upon vendor implementation whether it allows container to create multiple instances for serving multiple requests or to serve only one request while making others to wait requesting the same servlet .The only point here is that with standard servlet model one instance and multiple threads for serving different requests for same servlet.anyways we are not going to use single thread model.Am i right

Scjp 5.0
Prp for SCWCD5.0


Vishal Kumar<br />SCJP 5.0<br />SCWCD 1.5
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"vishal kr",
Please check your private messages.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Abi Ted
Greenhorn

Joined: May 24, 2008
Posts: 13
ah er hum....

isnt there something called container dependent?? :?
sudhakar karnati
Ranch Hand

Joined: May 03, 2007
Posts: 93
Hi All,

Even i had this doubt..now it is clear...
Can any body give me a link for resource where i can read about this.

Thanks & Regards,
Sudhakar Karnati
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
Can any body give me a link for resource where i can read about this.
Section 2.3.3 ("Request Handling") of the Servlet 2.4 specification.


Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
 
 
subject: how many instances???