Why is ServletConfig obj passed to init() of GenericServlet when the class implements the interface?
GenericServlet
implements ServletConfig
interface which means all the interface functions can be invoked from init()
function of GenericServlet
. Given this context, why does the Servlet container sends ServletConfig
object to init()
method? I would al开发者_开发问答so like to know if the ServletConfig
object that is passed to GenericServlet.init(ServletConfig)
different from GenericServlet object.
Regards, Ravi
The GenericServlet
implements the ServletConfig
methods by simply delegating to the config object passed to the init method. So it implements ServletConfig
simply for convenience - it then simply delegates. So instead of calling getServletConfig().getInitParameter()
you can call getInitParameter()
精彩评论