Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Servlet request processing by Web Server and Servlet container

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 470
    Comment on it

    1. Web Server

    alt text

    A web server is basically used to give the response to the request specified by the browser (user). It basically uses HTTP protocol for the transmission of data. eg. A user can request for some page by entering the web address and in turn gets response from the server.

    A web server contains the Servlet Container

    2. Servlet Container

    alt text

    A servlet container is basically use to generate web pages dynamically with respect to the request received from the web browser. The request is received by the web server and then it is forwarded to web container which loads the servlet to process that request.

    Servlet container is the container for Servlets.

    3. Servlet

    alt text

    Servlets can be defined as the server side pages residing on the web server inside the servlet container which process the requests for generating a dynamic web page. Servlet container forward the request to the servlet and it call various methods depending on the request and gives a dynamic response accordingly and response is sent back to the client.

    Advantages of servlet:

    1. It makes use of multithreading for serving various requests. This helps to reduce the traffic since the threads are light weight and it also saves memory.
    2. Since it is dependent on java, it is platform independent.  

    Let us discuss about the life cycle of a servlet . There are three phases of that:-

    1. init() :This method is called to initialize the servlet when it is loaded for the first time by the container for the first request.
    2. service():This method is invoked upon each request after its initialization. Each request is serviced in its own separate thread. The service() method determines the kind of request being made and dispatches it to an appropriate method to handle the request.
    3. destroy(): This method is invoked when the servlet object should be destroyed. It releases the resources being held.

    It shows that all the threads are loaded dynamically by the servlet and it is garbage collected by JVM when no longer needed.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: