When the project is deployed, the web container creates a ServletContext object. The web.xml file can be used to retrieve configuration information using this object. Each web application has just one ServletContext object. It is preferable to provide information from the web if it is shared throughout numerous servlets.\
The ServletConfig parameters are unique to one servlet and are not shared by other servlets. It is employed for the purpose of initialization. Outside of any specific servlet, the ServletContext parameters are set for an entire application and are available to all servlets within that application.
The getServletConfig() method of the Servlet exposes a ServletConfig object for each Servlet. A ServletConfig object has methods for retrieving initial parameters for a specific Servlet, as well as the getServletContext() function for obtaining the proper ServletContext instance.
ServletContext has a "application" scope, and its setAttribute("name", object) and getAttribute("name", object) methods can be used to communicate information across servlets inside the same application ("name").
The web container creates a ServletContext object for each Web application. The ServletContext object is used to retrieve configuration information from the Deployment Descriptor(web. xml), which is available to any servlet or JSP in the web app.
Share a personalized message with your friends.