Saturday, 5 October 2013

Web Container

  • A web container is a predefined application provided by a server, it takes care of the dynamic resource of a web application.
  • In a java based web applications, servlets and JSP’s are dynamic resources and the runtime support for then at the server will be provided by the container.
  • It consoles based java applications a class that contains main method acts as a container for other classes.

For Example:


Class service

{

Void withdraw()

{

---------

---------

}

Void deposite()

{

---------

----------
}
}
Class M
{
Public static void main(String args[])
{
Service s=new service();
s.withdraw();
s.deposite();
}
}

Here M class is providing runtime support for service class so main class is called a container.
In GUI based applications a frame acts as a container for other awt component like button, textField, textArea etc.

web container



IP address

Benefits of Container

Life Cycle Management
  • Servlets and JSP’s are dynamic resources of a java based application. The servlets or JSP’s will run on a server and at server side, a container will take care about life and death of a servllet / JSP.
  • A container will instantiate, initialize, service and destroy of a servlet or JSP. It means life cycle will be managed by a container.


Communication support

If a servlet or jsp wants to communicate with a server than apart from its business logics, some communication logic like socket and streams programming is also required in a servlet / JSP.
Implementing business logic is a burden on a programmer. Adding communication logic on a servlet / JSP will increase more burden on programmers.
To reduce the burden, a container act as a mediator between a server and a server / JSP and provides communication between them.

Multithreading

  • A container creates a thread for each request, maintains the thread and finally destroys it
  • whenever its work is finished.
  • By creating a web application, a programmer is no need of writing threading related logic because of the container.

Security

  • Some servlet / JSP’s of a web application are not accessible for all users.
  • A programmer is not required to write security code in a servlet / JSP. A container will automatically provide security for a servlet / JSP. If a programmer is informed to the container.

No comments:

Post a Comment