Container is a runtime environment for Java2ee aka j2ee apps. Servers provides predefinition of application with web containers and manage Servlet and JSP.

Java application includes a class of containers that works same for other classes in a console and has main methods as well/


class Vachile
void speed()
System.out.println(“Speed limit is 40 km/hr”);
class Mainclass
public static void main(String args[])
Vachile v=new Vachile();


Speed limit is 40 km/hr
On above java codes a machine is defining run time support for a vehicle class and main class contains everything so is called container.

In Graphic user interface based application awt components are expressed with frames acting as a container.

Operations of Container.

  • Life Cycle Management
  • Communication Support
  • Multithreaded support
  • Security etc.
  1. Life cycle management: Servlet and JSP both are automatic managed resource in web application built with java. Servlet or JSP can run only at server side. Container is defined to take care of life and death of Servlet and JSP. Servlet or JSP service can be started or killed with help of container and means cycle of running time of both is managed by container.
  2. Communication Support: In case of Servlet or JSP both want to communicate with servers other than they need some data to be exchanged like socket programming. Burden is increased on programmers when design concept is more complex but container helps to reduce burden by communicating between server and Servlet or JSP.
  3. Multithreading: Creating, maintenance and destroying of a thread for different purposes is done by container is called multithreading.
  4. Security: Container works as a security officer for Servlet and JSP and provides security to them and a programmer is not required to write security code.
  5. Security: A programmer is not required to write security code in a Servlet/JSP. A container will automatically provide security for a Servlet/JSP.