To Execute Java Apps we need JRE+JVM
To execute Applet programs we need Applet viewer
To execute Servlet programs we need Servlet Container or Web Container. Web Servers (Ex: Tomcat, WebLogic) supplies this Servlet, JSP containers.
The client sends the request to the web server and web server sends the request to the web container.
Responsibility of web container is to communicate with the servlet and allow to servlet to build dynamic content and sends the response back to the web container again.
Which will in turn sends the response to the web server which will ultimately go the client here we need to understand one thing HTTP request which sends the client and web container which sends the request is different.
So servlet is a java program which can only understand the objects (but not HTTP request) so Web Container converts the HTTP request into valid request object .
servlet does not have main() and it have call back methods(doGe()), that means web container knows what call methods call for the servlet . In the doGet() method we write the dynamic content.
All out business logic we will write either doGet() or doPost() methods.
Servlet call the doGet() and builds a response to the web container.
Again this response which was sent by the servlet is a java object.
Now web container converts the java objects into HTTP response and sends it back to the client.
Container Roles:
To execute Applet programs we need Applet viewer
To execute Servlet programs we need Servlet Container or Web Container. Web Servers (Ex: Tomcat, WebLogic) supplies this Servlet, JSP containers.
Responsibility of web container is to communicate with the servlet and allow to servlet to build dynamic content and sends the response back to the web container again.
Which will in turn sends the response to the web server which will ultimately go the client here we need to understand one thing HTTP request which sends the client and web container which sends the request is different.
So servlet is a java program which can only understand the objects (but not HTTP request) so Web Container converts the HTTP request into valid request object .
servlet does not have main() and it have call back methods(doGe()), that means web container knows what call methods call for the servlet . In the doGet() method we write the dynamic content.
All out business logic we will write either doGet() or doPost() methods.
Servlet call the doGet() and builds a response to the web container.
Again this response which was sent by the servlet is a java object.
Now web container converts the java objects into HTTP response and sends it back to the client.
Container Roles:
- Communication support
- Life cycle management (servlets live and die within the container): Container takes care of whole life cycle (birth to death) of servlet programming.
1. Object creation
2. Memory Allocation
3. Calling life cycle methods based on the events that are raised.
4. Execution of resources
5. Destruction of object.
- Multi threading support (every request is assigned by a thread
- Security (we write the code in side the container, only valid request can go throught servlets but not all the requests)
- jsp support
You may like the following posts:
No comments:
Post a Comment