Method getServletContextName()
returns the name of the \"web application\". That means, \"ServletContext\" is nothing but \"web application\". Ok.
API defin
A ServletContext is the runtime representation of the web application.
Context means web app here.
A ServletContextListener gets notified when a Web App is started or stopped. That way you can run tasks automatically that need to be run when the web app starts or stops.
ServletContext is interface that contain a set of methods to communicate with its own servlet container.
That allow servlets to gain access to the context for various parts of the server to communicate.
Life Cycle of ServletContext
Every servlet and JSP in the same web application will now has access to this ServletContext. ServletConfig vs ServletContext
The name is indeed, IMO, very badly chosen.
We must read ServletContext as "the general context of a servlet API based web application". Whereas we must read ServletConfig (another standard class) as "The config of a servlet".
They should IMO have named ServletContext as "WebAppContext" or "ApplicationContext", and ServletConfig as "ServletContext".
BTW, in JSP, the scope linked to a JspPage is named "page"; the scope linked to a HttpServletRequest is named "request"; the scope named to a HttpSession is named "session", and the scope linked to a ServletContext is named ... "application".
"Context" means.. context - it has contextual information and functionality for a particular web application:
ServletContext
is the context of a Java web application (because it uses servlets)
ServletContext implies Context or Runtime environment of servlet. Servlets runs in Servlet containers like tomcat. Servlet container creates and provides runtime environment for the servlet to get executed and it manages its lifecycle. It also holds other information, as :-