Hardly any use of user defined constructor in servlet! Generally in the classes, other than servlet, constructors are used to initialize instance variables. But instance variables itself in servlets are discouraged. I don't see any situation where actually you will require a user defined constructor.
Originally posted by Shahnawaz Shakil: But instance variables itself in servlets are discouraged.
Why ? Whats the big deal ?
Joined: Mar 22, 2005
Concurrency issues. Servlets are multithreaded, so unless instance variables are immutable they need to be protected from concurrent access. Since that's easy to forget or to get wrong, it's best to avoid mutable instance variables.
Joined: Aug 04, 2008
Hi Sagar, Following thread in this site will be helpful for you.