Friday, February 1, 2013

Head First Servlets and JSP: Chapter 1 & 2

1- in servlet we start a new light weight thread for each request, not a process like CGI
2- Servlets dont have a main() method, the container takes care of calling the servlet
3- The container provides lifecycle management, multithreading, security services to servlet.

How Container Handles a Request
1-the http request comes to the container
2- the container creates a HttpServletRequest request and HttpServletResponse response objects
3- the container find the correct servlet to call based on the url and create (or allocate) a thread for the request, it also passes the request and response objects to these threads
4- the container calls the servlet's service() method.
5- the service() method calls doGet() or doPost()
6- the doGet() generates the page and put it in  a response object.
7- the containers convert the response object to HTTP response and send it back to client
8- the container deletes the request and response objects.

How to map between URL and Servlet
sure the mapping done by deployment descriptor, the container reads and understand the descriptor and does the mapping

the first thing you map the url that the client see to servlet-name
then you map the servlet-name to the servlet class

Servlet, JSP and MVC

the controller is the servlet
the view is JSP
the model is POJO

Web container, EJB Container and JEE Application Server

Web Container: handles Servlet & JSP, TOMCAT is Web Container
EJB Container: Handles EJB
JEE Application Server: handles both of them

No comments:

Post a Comment