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

GenericServlet implements the ServletConfig interface, which means that all functions of the interface can be called from the init() function of the GenericServlet . Given this context, why does the Servlet container send the ServletConfig object to the init() method? I would also like to know if the ServletConfig object that is being passed to GenericServlet.init(ServletConfig) is different from the GenericServlet object.

Regards, Ravi

+6
source share
1 answer

GenericServlet implements ServletConfig methods by simply delegating the configuration object passed to the init method. Thus, he implements ServletConfig just for convenience - he then simply delegates. So instead of calling getServletConfig().getInitParameter() you can call getInitParameter()

+3
source

Source: https://habr.com/ru/post/899301/


All Articles