Saturday, April 28, 2012

Introduction to web containers

Overview of web containers:
This tutorial provides the basic introduction to J2EE web containers (Also called Servlet container or Servlet engine).
In J2EE architecture the basic purpose of the container is to provide the runtime environment for the components. components are managed by container, in order to be managed by container components must follow certain contract. J2EE specification defines contract between components and container, and specifies the deployment model for components. Contract specifies how components should be developed and deployed, and how components can access services provided by container. When developing applications with J2EE, we develop components that follow the contract defined in the specification.
In J2EE this contract is specified in term of various interfaces and classes, developer writes the classes that implements this interfaces or extends the classes and provides appropriate implementation of various methods and rest will be done by container. Container takes the responsibility of instantiating, initializing and invoking the components. Application does not directly instantiate or invokes components. As you will see that application never instantiate an object of servlet or call any of the init(), service() or destroy() life cycle method, all of these is handled by web container. Web container automatically instantiates and initializes the Servlets on application startup or when invoked for the first time. Container calls the service() method when user requests the servlet.
The web container is a Java runtime environment which is responsible for managing life cycle of JSP pages and Servlets.
A web container is responsible for instantiating, initializing and invoking Servlets and JSP pages. The web container implements Servlet and JSP API and provide infrastructure for deploying and managing web components. The web container is part of web server or application server that provides the network services over which request and response are sent. A Web container is may be built into the web server or it may be installed as an additional component to a web server. As per the specification, all web containers must support HTTP protocol however it may support addition protocols like HTTPS.
Web container is also called servlet container or servlet engine. We will use Tomcat throughout all the tutorials. Tomcat is an open source web server, which is the web container reference implementation. You can find more information about tomcat at http://tomcat.apache.org/. If you have not already downloaded and installed Tomcat, read this tutorial Setting up a Servlet development environment which explains how to install tomcat and setup the environment. We will need to setup the development environment to run the various examples and code sameples given throughout the tutorials.
Note: Servlets and JSP pages are collectively called web components.

No comments:

Post a Comment