This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Suppose that you have a servlet which can not service client requests unless you initialize it properly. ServletConfig is used for initializing a particular servlet, and holds the servlet specific init-parameters configurable through deployment descriptor. When the servlet instance is created container creates a corresponding ServletConfig object and calls the servlet's init(ServletConfig) method passing the servletConfig object. Which can be used for obtaining the init-parameter information from it.
ServletConfig is one per servlet.
Similarly if you want that all of your servlets have access to same initialization parameters then instead of copying them in all the servletConfigs you can use ServletContext's init-parameters (context-param). ServletContext is one per web-application. so all the servlets share one ServletContext.
Besides it, ServletContext can also be used for sharing Objects by setting attributes.