Servlet Container


Prev Tutorial Next Tutorial

Container in Servlet

Container provides runtime environment for Java2ee (j2ee) applications. A web container is a predefined application provided by a server, its takes care of Servlet and JSP.

In console based java applications a class which contains main method acts as a container for other classes.

Container in Servlet Example

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

Explanation: Here Mainclass is providing run-time support for vehicle class so main class is called a container.

In GUI based applications a frame acts as a container for other awt components like button, textfield etc.

Operations of Servlet Container.

  • Life Cycle Management
  • Communication Support
  • Multithreaded support
  • Security etc.

1. Life cycle management: Servlet and JSP are dynamic resources of java based web application. The Servlet or JSP will run on a server and at server side. A container will take care about life and death of a Servlet or JSP.
A container will instantiate, Initialize, Service and destroy of a Servlet or JSP. It means life cycle will be managed by a container.

2. Communication Support: If Servlet or JSP wants to communicate with server than its need some communication logic like socket programming. Designing communication logic is increase the burden on programmers, but container act as a mediator between a server and a Servlet or JSP and provides communication between them.

3. Multithreading: A container creates a thread for each request, maintains the thread and finally destroy it whenever its work is finished.

4. Security: A programmer is not required to write security code in a Servlet/JSP. A container will automatically provide security for a Servlet/JSP.

Prev Tutorial Next Tutorial


Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: or 9999595223

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements

Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: or 9999595223 Try this Keyword C++ Programs