why a servlet has to implement ServletConfig interface?
Servlet Please go through the Servlet interface. I dont think there is any hard coded rule saying that a servlet has to implement ServletConfig. Moreover the servletConfig object is made by the container and passed to the init(servletConfig) in your servlet.
Servlet interface doesn't implement ServletConfig. But, why does GenericServlet? Already it HAS-A ServletConfig! In spite of this, what is the purpose of implementing a ServletConfig? I find it difficult to agree with this sentence: "A servlet IS-A ServletConfig". It's confusing.
Even I am preparing for SCWCD and am curious to know. If a servlet IS-A servletConfig why does the container has to pass a servletConfig to servlet:init(ServletConfig)?
(this is altogether a different question from the original)
Thanks for your thoughts
As a bit of a history lesson (for those who have not been using the Servlet API for a dozen years or so...), GenericServlet originally did not implement ServletConfig; that was something that got added later as a convenience. So the ServletConfig object passed in via the init method was the one you had to use.