开发者

Why is ServletConfig obj passed to init() of GenericServlet when the class implements the interface?

开发者 https://www.devze.com 2023-04-13 05:14 出处:网络
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 send

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

精彩评论

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