What r the roles of a constructor inside a servlet ? Why do we need constructors? can we have OVERLOADED CONSTRUCTORS INSIDE A SERVLET?
Thx in advance..
Cheers Rama Krishna Chowdary
posted 11 years ago
There's no need to use a constructor in servlets, because: 1) Web container will create servlets using default constructor. So, you can't overload constructors 2) The web container's services may not be accessible during instantiation of the servlet, so you can't use the constructor for such tasks, as database connection creation, JNDI lookups and so on. Use init() method instead.