ServletConfig vs ServletContext:

-There is one ServletContext object for one servlet but only one ServletContext object for one web app and for each servlets inside that web app.

-ServletConfig is used tp pass deploy-time information to the servlet but ServletContext is used to access web app parameters.

-ServletConfig object is used to get the ServletContext.

-ServletContext can be used to get server info, name and version of container, the version of API that is supported etc, which can not be got by ServletConfig.

-ServletConfig object holds the reference to the ServletContext.
We can create ServletContext object like this,

1 comment: