Suppose 10 clients requests for a Servlet. How many servlet instances are created? Also will it create any concurrency modification problem if each instance is trying to make changes? Please help.
Usually only one instance of the Servlet object is created. But some advanced containers might create more than one instance under certain circumstances. Even so, there is a difference between static class variables and instance variables.
You are right, Only single instance of Servlet is created, but that instance is shared across multiple threads.
1) How many objects of a servlet is created? Only one object at the time of first request by servlet or web container.
2) Servlet instance is created The servlet instance is created only once in the servlet life cycle.
Only one instance of servlet exist (per classloader) , and each request will be served on its own thread
So is there any thing that is shared amongst requests you need to manage synchronization
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With