Welcome to “Algorithms and the Beauty of Programming” ↑ pay attention to us!

This article was first published on the wechat official account “Beauty of Algorithms and Programming”. Please follow us and learn more about this series of articles in time.


I. Problem description

Recently, I worked with my senior to build the tourism big data platform project, in which I was mainly responsible for building the front end of the platform. Since this project is a big data platform for teachers, students and external personnel, at the beginning of the platform construction, we first consider how to find a suitable Web application server for this Web platform. Here we share the Tomcat server we have learned about.


Ii. Problem analysis

In our actual web development, we need to understand the role of servlet, servlet can be understood as a server-side Java program to process data, and for the management of servlet, we need to use the Web container.


What is a Web container?

In terms of my understanding of this issue, I also felt it was abstract at first, but after consulting a large amount of data, I can make the following preliminary summary: Servlets have no main method, so we need a program or application to control how to start, close, and find these operations. Such a program or application is called a Web container.


So what exactly does the Web container do?

Once the servlet is managed by the Web container, what are the benefits of doing so?

1. Communication support

Using the method provided by the container, we can easily implement the servlet to the Web server dialogue. Otherwise, you have to create your own server search band-Aids, listen to ports, create new streams, and a series of complex operations. The existence of a container helps us encapsulate this complex set of operations.

2. Lifecycle management

The container is responsible for the entire life cycle of the servlet. How to load classes, instantiate and initialize servlets, call servlet methods, and make servlet instances garbage collector. With containers, we don’t have to worry about things like resource management and garbage collection.

3. Multithreading support

The container automatically creates a new Java thread for each servlet request it receives, and when the servlet runs, the container automatically terminates the thread.

4. Declarative security

With containers, you can configure security using XML deployment description files rather than having to hardcode it into servlets.

5. The JSP support

The container translates JSPS into Java

Iii. Solutions

Among the numerous Web containers, according to the functional requirements of the project platform we developed and the concept of excellence, we finally chose Tomcat, a product belonging to the Apache Software Foundation. Here we introduce the configuration process of Tomcat in Idea:

1. First download the Tomcat installation package of the required version and decompress it into the folder

Tomcat 9 is downloaded here

Zip (64-bit Windows Zip (PGP, MD5, SHA1)) is installed free. Exe (32-bit or 64-bit Windows Service Installer (PGP, MD5, SHA1)) is installed. Also check whether your computer is running on a 64-bit or 32-bit system.

The downloadable version is selected here


2. Configure Tomcat in Idea

2.1 Click on R un-Edit Configurations…



2.2 Click the + button on the left and select Tomcat Server-local


Under Tomcat Server -> Unnamed -> Server -> Application Server

Click Configuration, locate your local Tomcat server, and click the OK button


At this point, Tomcat configuration in Idea is OK.

Four,

For the use of Tomcat, I have just started, for its principle of use to understand about, so can only carry out basic operations, has not yet understood the command line to operate Tomcat, but I believe that with in-depth learning, no matter how difficult the knowledge is not difficult, I hope this article can just start small sprout new people have some help!

More interesting articles:

Where2go team



Wechat: The beauty of algorithms and programming

Long press to identify the QR code to follow us!

Tips: Click on the lower right corner of the page “Write a message” to comment, looking forward to your participation! Looking forward to your forwarding!