ServletContext is an interface present in java API. the job is to communicate with servlet container.
the servlet context interface contents some methods that can be used to communicate with servlet container.
as it is an interface we can not create the object directly using new keyboard but the servlet engine already crated the object and we can get this object using the getServletContextMethod() as sample: ServletContext sc = getServletContext(); although we can call getServeletContext method directly but this method will be called on servlet config object. only one servlet context object will be available per web application.
methods present in servlet context: 1-getAttribute(String name) and return type of this method is object and input argument is string and the job is to retrieve data from servlet container with described name. 2-setAttribute() it takes 2 argument one is String and another is the object. the job is to store the Object in Servlet Container by providing a name. 3-getRequestDispature(String path): it will return the object of request dispature interface on that path.