ServletContext translated as "Servletcontext ". is aservletwith theservletinterface for direct communication between containers. J2sdkeeof theJavadocsaid it was "a set of methods that a servlets uses to communicate with its servlet container."ServletThe container starts aWebwhen applied, it creates aServletContextobject. EachWebthe application has a uniqueServletContextobject. With oneWeball of the appsservletobject to share aServeltcontext. Servletobject can access various resources in the container through it.
in the program, you can put ServletContext understood as a package that holds global variables
ServletContextobject is contained in theServletConfigobject,ServletConfigobject is initialized in theServletwhen theWebserver is provided toServlet.
in theServletcontainer, eachServletContextThere is usually only one instance. WhenWebcontainers are distributed when deployed on multiple machines, the oneServletContextin eachJVMhas an instance on it.
ServletContextThe properties in the localJVMcan not be run in a distributed environment in otherJVMin theServletaccess, if you need to share data in a distributed environment, you can store the data inSession, the database orEJBthe.
in theServletcontainer, but no deployedServletis also permissible, thisServletbelongs to a defaultServletContext, this defaultServletContextcannot be distributed to multipleJVMon.
Web The server may support multiple domain names to share a IP address, this configuration is called a "virtual host." In this case, each virtual host must have its own ServletContextandcannot share a servletcontext.
Application (ServletContext) problem with load balancing