Forums Register Login

Instance Pooling

+Pie Number of slices to send: Send
Hello
I have one question about instance pooling
Can a programmer control the number of instances for servlet & JSP by specifying no. in any tag in deployment descriptor?
This is possible in EJBs
thanks in advance
Have a nice time always.
+Pie Number of slices to send: Send
 

Can a programmer control the number of instances for servlet & JSP by specifying no. in any tag in deployment descriptor?



If you are not implementing single threaded modle then only one instance of Servlet or jsp (converted to servlet) will serve all the requests.
+Pie Number of slices to send: Send
 

Originally posted by Praful Thakare:


If you are not implementing single threaded modle then only one instance of Servlet or jsp (converted to servlet) will serve all the requests.



just want to add a word in this.

If you are not implementing single threaded modle then typically only one instance of Servlet or jsp (converted to servlet) will serve all the requests.[/QB]
+Pie Number of slices to send: Send
Well, i am not talking about SingleThreadModel. in normal case can we control no. of instances those are created by Server in case of Instance Pooling by specifying some no. in Deployment descriptor?

thanks.
+Pie Number of slices to send: Send
 

Originally posted by Shrinivas Mujumdar:
can we control no. of instances those are created by Server in case of Instance Pooling by specifying some no. in Deployment descriptor?



Well I haven't tried this ...

1. Create a class level variable.
2. Verify against no. of instances /Increment it by one in constructor of class.
3. If variable is exceeding no. of instances to be expected throw an custom exception from your cunsturctor that no more instance can be created.

adeel what is your view
+Pie Number of slices to send: Send
 

Originally posted by Shrinivas Mujumdar:
Well, i am not talking about SingleThreadModel. in normal case can we control no. of instances those are created by Server in case of Instance Pooling by specifying some no. in Deployment descriptor?

thanks.



Ok, now i am also not talking about SingleThreadModel. typically all the request are entertained by only one instance of the servlet. your question would become more rational if talk about SingleThreadModel. Because there is an instance pool when implementing SingleThreadModel.

I dont think we have any that kind of element in deployment descriptor. it depends on the container implementation how it deals with the requests.

when it needs to maintain an instance pool
when need to add more instances to the pool
when need to discard instances from the pool

How can we decide how many instances should be in the pool, or should not be there??
[ October 19, 2004: Message edited by: adeel ansari ]
+Pie Number of slices to send: Send
 

Originally posted by Shailesh Chandra:


Well I haven't tried this ...

1. Create a class level variable.
2. Verify against no. of instances /Increment it by one in constructor of class.
3. If variable is exceeding no. of instances to be expected throw an custom exception from your cunsturctor that no more instance can be created.



Chandra, it could be an approach but ...

its not good to override the servlet class constructor, whatever we like to do at construction time we should do that in init() method. and init() method executed only once.

or may be i haven't got you properly.
+Pie Number of slices to send: Send
Agreed..

it is not good approach !!!

I am just looking possibility if sometime we face such critical requirement.
+Pie Number of slices to send: Send
 

typically all the request are entertained by only one instance of the servlet.


It is NOT just TYPICALLY, it is ALWAYS. The servlet API says specifically that if you have a single servlet container (ie Tomcat) running, it will create ONLY ONE instance of a servlet per servlet declaration. Section SRV 2.2 of the servlet 2.4 specification.
Everybody seriously interested in servlets and JSP should have copies of the published APIs. http://java.sun.com/products/servlet/ is a good place to start.
Bill
+Pie Number of slices to send: Send
i have got this word typically from J2EE Tutorial from sun's site. anyways got it now.
+Pie Number of slices to send: Send
Although only 1 instance per servlet, there can be multiple threads of the same servlet running at the same time. Strange error can occur if the servlet is not coded thread safe.
On top of spaghetti all covered in cheese, there was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1253 times.
Similar Threads
Difference between Bean pooling & instance pooling???
cache and pool
Questions on EJB
user defined instance pooling
How to create a pool of prototype beans?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:06:44.