Reputation: 673
Method getServletContextName()
returns the name of the "web application". That means, "ServletContext" is nothing but "web application". Ok.
API defines:
a ServletContextListener receives notifications about changes to the servlet context of the web application they are part of.
What does "servlet context" of the "web application" mean? What actually is "Context" in "ServletContext"?
Upvotes: 22
Views: 10368
Reputation: 691715
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".
Upvotes: 22
Reputation: 11420
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 :-
Upvotes: 1
Reputation: 673
A ServletContext is the runtime representation of the web application.
Upvotes: 4
Reputation: 597076
"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)
Upvotes: 10
Reputation: 298898
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.
Upvotes: 6