开发者

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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜