Analysis of Servlet Web Applications

Source: Internet
Author: User

A powerful feature of Java Servlet APIS is its ability to easily process form data. Unlike the search for environment variables in traditional CGI development, you can use Servlets to access forms and query string data by calling Java methods. Let's take a look at how it works. You can download the sample code here.

Load Servlet

When a Servlet is loaded, the Servlet engine calls the Servlet init method. This method is called only once when the Servlet is loaded, and the configuration data is passed in the form of an instance of the ServletConfig class. The ServletConfig object contains information about the Servlet engine and Servlet runtime environment.

The ServletConfig object exposes initialization data to the Web application operated by the Servlet. Use the getInitParamete (StringparamName) method to access this data, as shown in Listing.

Before destruction

The Servlet class exposes a method called destroy, which is called by the Servlet engine when the Servlet is uninstalled normally. This method is called when all the Servlet threads are uninstalled or the specified time is exceeded. It is used to save Servlet or clear resources. For details, see Listing B.

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.