The ServletConfig parameters are for a particular Servlet.
HttpServlet extends GenericServlet implements ServletConfig, myServlet.getInitParameter(paramName)<servlet>
<servlet-name>MyServlet1</servlet-name>
<servlet-class>com.MyServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/config/config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
The ServletContext parameters are specified for the entire Web application.
In the case of a web application marked "distributed" in its deployment descriptor, there will be one context instance for each virtual machine. In this situation, the context cannot be used as a location to share global information (because the information won't be truly global). Use an external resource like a database instead. The
ServletContext
object is contained within theServletConfig
object, which the Web server provides the servlet when the servlet is initialized.Servlet.getServletConfig()
,ServletConfig.getServletContext()
<context-param>
<param-name>GlobalClassName</param-name>
<param-value>MyWebAppClass</param-value>
</context-param>