why init method used in servlet?
The init() method is called only once by the servlet container throughout the life of a servlet. By this init() method the servlet get to know that it has been placed into service.
and also init() method is one in servlet life cycle methods. lifecycle methods of servlet. 1)init() 2)service(request,response) 3)destroy() init() is initialisation of servlet class.and also all resource initialization code like jdbc connection creation code are wrote inside the init()method .and also all initparams in web.xml we can get through config object.by passing that object into init(config).but for resource initialization here mean inside init() is not good practice said by experts.now a days almost this init(config)method using in realtime for counting how many times user entered or hit the webpage.not only that all web.xml init params are placed in config object passed through init()method .from here all init params we can collect or read.or for counter purpose also we use init().