Getting Started with Java (d): What is Servlet

I. Overview of Servlet

  • What is Servet

    • Java is a small program that runs on a web server, and in response to receiving a request from a client over, typically using the HTTP protocol

  • The role of the Servlet

    • It used to process request from a client over, and responds

  • to sum up:

    • We send a request from the browser client to the server, submit the data. Where to submit Servlet, Servlet can receive parameters submitted over, and then make some background for logical processing parameters, the final result of the process of sending a response to the browser client.

Two, Servlet life cycle

  • The life cycle of an object is the process from creation to destruction

  • Servlet life cycle: Servlet process from creation to destruction

    • When to Create: Create Servlet instance when the user first accesses Servlet

    • When destruction: When an item is removed from the server, or shut down the server when the destruction of Servlet

  • When users first visit Servlet, the server creates a Servlet instance, it will call the init method instance after instance is created. Any time request that the server creates a new thread to access the Servlet's service method. DoXXX call different methods depending on the service request internally methods (get request call doGet, post request is called doPost). When the Servlet server is removed or shut down the server, Servlet calls destory method, and then the destruction of Servlet examples

Three, Servlet roughly call the process diagram:

 

Please indicate the source: https://www.cnblogs.com/Infancy/p/12503409.html

Guess you like

Origin www.cnblogs.com/Infancy/p/12503409.html