can you make a servlet as singleton.. this is a question asked in an interview..
According to my knowledge , as the servlet object is created by the container , we can't create it.. as it calls the default constructor while creating servlet.
The only method i know to make an object singleton is 1) making its constructor private and 2)giving factory methods which gives objects ... (which returns only one object .. and returns the same on further calls..)
But the first point , making constructor private is not possible when servlet calls the constructor..
.................
But I have a doubt, the Action Servlet in Struts framework is singleton .. that means there is way to create a singleton servlet .. ...
So .. tell me if there is any way.. and correct if Iam wrong in any of the things...