Java Web First servlet program

Source: Internet
Author: User

About Servlet

. Java servlet is a server-side component that is not related to the peace platform, and it runs in the Serlet container. The servlet container is responsible for the communication between the servlet and the client and the method of invoking the servlet, and the servlet communicates with the client using the request/response pattern.

The servlet can do the following functions:

-Create and return dynamic HTML pages based on customer requests

-Create a partial HTML page that can be embedded in an existing HTML page.

-Communicates with other server resources, such as databases or Java-based applications.

To access the Servlet class in a browser way, you need to configure and map the servlet.

servlet container: A software environment that runs Servlet, JSP, filter, and so on.

1. You can create a servlet and invoke the servlet's lifecycle method

2.jsp, Filter,listener,tag

Servlet Life cycle Methods: The following methods are called by the Sevlet container

1 constructor: Called only once, and only when the servlet is requested for the first time, the servlet instance is created and the constructor is called. This shows that Sevlet is a singleton.

2.init is called only once, and is called immediately after a good instance is created to initialize the current servlet.

3.sevice: Called multiple times, each request invokes the service method. Actually used in response to a request.

4.destroy: Called only once, before the Web app where the current servlet resides is unloaded. Used to release resources occupied by the servlet.

Java Web First servlet program

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.