Servlet Mastering Cookie Illustration

Source: Internet
Author: User

The life cycle of the servlet

The servlet is a class file that inherits the HttpServlet servlet is a server applet that provides a unified programming interface for Servlets servlet typically runs common servlet container tomcat in a container, Jetty/resin

Servlet life process: Refers to the entire process from creation to invocation of a Servlet object in server memory, to destruction

1:classloader---Loading

2:new---Instantiation: When a client requests through a URL, the Web container automatically calls the Servlet's construction method according to the XML configuration, instantiating the object

3:init ()---Initialization: Call the Init () method from the Servlet object, read the configuration information of the servlet in Web. XML, and provide the relevant data for the service method

4:service---Processing requests call the service () method through the object, and if it is inherited HttpServlet, the corresponding doget ()/dopost () is invoked according to the request method in the request header information

5:destory ()---Exit service: is not called immediately after the service () method call, but is determined by the JVM. The Destroy () method of the instance is called when the JVM needs to destroy some objects and free up memory space

To run the servlet, you must also configure a Web. xml file registration mechanism to find the class file that needs to be run


@WebServlet ("/servletlife")//----If you add annotations without Web. xml

So how do you master a servlet?

First 1. Create a servlet to inherit from HttpServlet

Overriding the Doget/dopost method in the Web. XML configuration

Servlet life cycle

The concept of cookie/session/application

Request Forwarding

Servlet Cookie

Servlet Mastering Cookie Illustration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.