This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
The term constructor does not relate to a servlet. Basically a constructor for a particular class is used to initialize some variables or do process which is necessary when an object for that particular class is created. In case of servlets its not so.. when you access a servlet, a thread is created for that particular request which does the necessary processing .. its not like instantiating an object. And one more thing just in case you want that certain parameters be initialized or whatever , when the servlet is first loaded in the memory or the servlet is first called , then use the init() method for that purpose. by the way whatever code you write for the servlets constructor will get executed that too only once .. ( i guess ) when the servlet is first called. better confirm it i hope this helps bye [ March 04, 2002: Message edited by: Dharmesh Chheda ]
Naturally your custom servlet class will have a constructor that will be called in the normal way when the servlet engine needs an instance. This will be either on startup or when first requested. The servlet engine expects a no-args constructor. It is bad practice to use a custom constructor with servlets. As Dharmesh said, the servlet engine is NOT going to be building an instance for every request and you are expected to use the init method for any initialization. Bill