If my Servlet
class uses a singleton (such as a manager class), where should it be stored? The servlet itself, or in the ServletContext
?
Can a servlet container create more than one instance of my Servlet
class to handle requests?
It is certain that there will be only one instance of a Servlet. But still, it's better to store it in the ServletContext
. Thus it will be accessible from other servlets as well.
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