I didn't understand the exact reason why GenericServlet implements ServletConfig. A servlet will receive its configuration object through init(ServletConfig) which is called by the container itself. This object will stay with the servlet till it dies. So, what's the point in implementing ServletConfig? Doesn't this look odd: a servlet is aServletConfig ?
every servlet can have a configuration object. when we say class Ball implements Bounceable, we can think this as that a ball has the property of bouncing. it can bounce. extending the analogy to GenericServlet implements ServletConfig we can say that a generic servlet has a configuration stuff associated with it, which is very much reasonable.
Also, think about if you can initialize servlet with init(), then Servlet can also able to get ServletConfig object through getServletConfig() method (How it will get that Object?).
Gaurangkumar Khalasi wrote:ServletConfig is an Interface, can't be instantiated.
GenericServlet and HttpServlet implements ServletConfig, So they have to give implementation to the abstract methods of it.
init(ServletConfig) and init() methods are two initialization methods.
Also, think about if you can initialize servlet with init(), then Servlet can also able to get ServletConfig object through getServletConfig() method (How it will get that Object?).
but i think we are deviating from the original topic , which is as to WHY generic servlet implements ServletConfig. the clever answer would be thats how the spec implementors thought of GenericServlet class which abstracts Servlet Functionality