As already discussed servletConfig is not available in the constructor so init would be the right place to initialize.You you want to initialize something which is not dependent of context of servlet config then you can do that as well in the constructor (its not a preferred way of doing thogh)
destroy() is a callback method called by the container .. you can explictly call that but in that case that is just like any other method in the class ..no use..destroy is called by the container when its about you destroy the servlet (for running some code for cleaning )..
its something like overriding the finalize (in Object class)method and calling that with the hope that this would garbage collect the object.
But What is basic Difference between Constrctor() & Init() mthod ?
Regards. Anil Borude
Joined: Nov 29, 2005
constructor is called while creating a object (its actually not a method) and init is a method ..A callback method called by the container after the constructor is called and it has servletConfig's reference.