I want to know what is a singleton servlet and how to create it?
Any instructions will help.
maybe you need a "startup servlet" which runs 1 time when the application server starts.
Singelton servlet is similar to having a single instance of any POJO in the JVM.
To achieve a single instance of servlet being loaded in the container, you can go by implementing the singleThreadModel interface. This being a marker interface will tell your container that a single instance is to be maintained.
But beware, this interface is deprecated from servlets 2.3 onwards and also by implementing this interface you can face performance problems as the container will que all your request to this servlet instance.It actually makes the service() synchronized and ensures no other thread gets the service() when some current thread is executing.
According to my understanding by default Servlet is singleton. It will create multiple threads to process multiple requests, but it doesn't create multiple instances of a servlet.