The interaction between servlets and clients is performed through the HTTP protocol, which the protocol that the web container must support it also.
The Java Servlet API is one of the most important technologies included in the J2EE platform, providing utility in building dynamic content. It is directly related to another successful technology, Java Server Pages. Regarding the approaches, the java servlet is similar as role and objectives with other technologies like ASP.
A servlet is a java class that can be loaded dynamically an run by a special web server. The object of such class has the role to receives requests (ServletRequest) and generates a response (ServletResponse) based on the request. The API package javax.servlet.http defines the HTTP subclasses of the generic servlet (HttpServlet) request (HttpServletRequest) and response (HttpServletResponse) as well as an (HttpSession) that manages multiple requests and responses between the web server and the client.
For detailing better a servlet, first the web container must be defined: fisrt of all this is also called servlet container or servlet engine. This is the component of a web server that interacts with the servlets. The web container is responsible for managing the lifecycle of servlets, mapping a URL to a specific servlet and ensuring that the URL requester has the correct access rights. The servlet is loaded by the server container the first time is requested and stay in memory unless not sufficient memory space.
The flow-chart of the actions performed by a servlet inside a servlet container are exemplified in the Fig 10. The server is loaded by the servlet container the first time the servlet is required. After it performs the response processing, it stays in memory unless the servlet container depicts a shortage of memory.
The steps of processing in the case of Servlet are:
o When the servlet container receives a request, it sends forward to the respective servlet
o The servlet processes the request and sends the output back to the servlet container
o The servlet container sends to the client the response from the servlet