JAVA advanced Tomcat introductory teaching

Tomcat use

Server related concepts

What is a server?

Server: divided into software server and hardware server.
Hardware server: a computer with a static IP running on the Internet (usually with a higher configuration).
Software server: a computer program (software) running on the Internet. The server software is installed on the Only the hardware server can provide external services.
There are many types of server software: database server (MySQL, Oracle, SQL Server, etc.), node.js, Web server (tomcat, jetty, jboss, etc.), mail server, FTP server.

What is tomcat?

It is a web server similar to nodejs.
The main function of nodejs server is, Vue files are compiled into JavaScript5 (ES5)
tomcat to run the code, and mysql is operated through jdbc

In the work, you may encounter old projects, you need to:
deploy the program in the tomcat\webapps folder, bin\startup.bat, conf\server.xml, the
new project uses:
springboot, built-in tomcat

Open cmd to view the public network ip address, which is different across the country

Insert picture description here

What web server?

Web server: A computer program running on the Internet, specifically used to receive client requests, process them according to the request, and finally give a response! For
example: open the browser, enter "http://www.baidu.com" and press Enter, In fact, you are visiting Baidu's server. At this time, a request will be sent to the Baidu server to request Baidu's homepage. The Baidu server will receive and process the request, and respond according to the request (response the Baidu homepage to the client browser)
Insert picture description here

Tomcat is a web server, which is characterized by: small and flexible, simple and easy to use, and the learning cost is very low!

Tomcat server download, install, start, configure

Tomcat is similar to nodejs, receives get requests, returns web pages, pictures, json, and executes jdbc in tomcat

Link: https://pan.baidu.com/s/1Zf9xDlNd1O-ABSlQAmP0jw
Extraction code: jol5

Install Tomcat

Installation: It can be used after decompression (it is best not to include Chinese and spaces
in the installation path). Before starting, you need to configure (check) a JAVA_HOME environment variable, which needs to point to the installation root directory of the JDK.
Variable name: JAVA_HOME
variable value: C:\Program Files\Java\jdk1.8.0_241
Since the tomcat server is developed by the Java language, running tomcat requires JDK support. The
JAVA_HOME variable tells the tomcat server which location to use the JDK.

Start Tomcat

Start tomcat: start the tomcat server through the [tomcat installation directory]/bin/startup.bat file;
close tomcat: close the tomcat server through the [tomcat installation directory]/bin/shutdown.bat file;
or directly click the cross in the upper right corner

After starting tomcat, you can open the browser and visit:
  http://localhost:8080
  http://127.0.0.1:8080

Insert picture description here

If you can access the homepage of the tomcat server, it means that the tomcat is installed and started successfully!

Insert picture description here

Modify the default port of the tomcat server

Insert picture description here

If you do not modify the port, every time you access the tomcat server, you need to add: 8080 after the host name/ip address: 8080
If you want to add a port after the host name or ip address you are accessing, you can modify the port to 80 (this port Special, you can omit it!)

The way to modify the port is:

Find [tomcat installation directory]/conf/server.xml and open this file with a text editing tool.
Find line 69 of the file, change the port attribute value on the Connector tag to 80, save the file, and restart the server to take effect! After
Insert picture description here
restarting the server , You can access the tomcat server through the following path:

  http://localhost
  http://127.0.0.1

Deploy the website on tomcat

Link: https://pan.baidu.com/s/1QRQQVlTBYu1sUqSPdn2Uaw
Extraction code: cpbh

After the download is complete, copy and paste person to deploy to tomcat/webapps

Insert picture description here

Visit the image and index.html in the browser, then tomcat

http://localhost:80/person/index.html
Insert picture description here
http://localhost:80/person/image/money.jpg
Insert picture description here

Deploy person to webapps/root

Visit the picture and index.html in the browser
http://localhost:80/

If you cannot access it, the port may be occupied. The solution is to find the software that occupies the port.

Guess you like

Origin blog.csdn.net/QQ1043051018/article/details/112599572