ServletConfig is a configuration object used by a servlet container to pass information to a servlet during initialization. Before calling the service method to a request it calls the init(ServletConfig) to initilize the servlet. At this time it loads all the params the servlet needed. If you need some parameters specific to a Servlet you can make use of <ServletConfig> in deployment descriptor file. The init parameters in <ServletContext> are for the entire application(i.e, every servlet in the application can make use of the init-parameters in the ServletContext).
Look at the below example..
<web-app>
<context-param>
<!-- The TCP port of application server.-->
<param-name>APPLICATION_SERVER_PORT</param-name>
<param-value>7777</param-value>
</context-param>
<servlet>
<servlet-name>SERVLET</servlet-name>
<servlet-class>WEB.MYSERVLETS.SERVLETCLASS</servlet-class>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
</web-app>
In the above deployment descriptor file the param-name "APPLICATION_SERVER_PORT" is needed for all the servlets that is why it is kept in context-param( instead of writing that for each and every servlet). Where as for the param-name "validate" is for the servlet only in which it is mentioned. It loads all of the parameters that are mentioned in <servlet-config> before it calls service method.
Suggestion:
Try to reduce the usage of number of context-params. Because these are not
thread safe.