I am confused with the concept interface in Servlet. I want to make sure i understand what i am working on. So any explanations will be much appreciated.
public class Testing implements Servlet
{
public void init(ServletConfig arg0) throws ServletException
{
/* getting some values from web.xml } */
}
}
(i) init will be called by tomcat
(ii) ServletConfig is an interaface, How can an interface object can be created ?
arg0might be a reference ofServletConfigbut it is pointing to an object of class implementingServletConfig..Eg: –
Assume here that
interface AisServletConfig, andclass Bis the class implementingServletConfig.. Now you can passobjwhich is of typeAand point to object of classB, to any method..