Tomcat Server Getting Started Super Detailed Tutorial

Tomcat Server Getting Started Super Detailed Tutorial

1. Some concepts of Tomcat

–1, Server

Server: Divided into server hardware and server software. Only after the server software is installed on the hardware server (actually a computer) can services be provided to the outside world.
1. Hardware: usually refers to a computer with an independent IP on the Internet, usually with a relatively high configuration. For example, our own computer can also be used as a server (but the configuration is lower)
2. Software: It is a computer program, such as MySQL server software and tomcat server software. Server software is divided into many types, such as: ftp server, database server, mail server, web server software, etc.

–2, web server

A computer program accessed through a browser. When the server receives your access request, it processes it and responds.

–3, Tomcat server

Tomcat is a core project of the Jakarta project of the Apache Software Foundation. Because of its advanced technology, stable performance, and free, Tomcat is deeply loved by Java enthusiasts and recognized by some software developers, becoming a popular Web application server.
Tomcat server is a free and open source Web application server. It is a lightweight application server and is widely used in small and medium-sized systems and in situations where there are not many concurrent users. It is the first choice for developing and debugging JSP programs. For a beginner, you can think of it this way: when the Apache server is configured on a machine, it can be used to respond to access requests for HTML (an application under the standard universal markup language) pages. In fact, Tomcat is an extension of the Apache server, but it runs independently at runtime, so when you run tomcat, it actually runs separately as a process independent of Apache.

Second, use Tomcat

–1, Download and install

No need to install, just unzip it (the path should not contain Chinese spaces, etc.)
The latest version is Tomcat 10. We can use Tomcat 8 because it is relatively stable. Before using Tomcat,必須要安裝好jdk,并配置好環境變量JAVA_HOME

-2, Startup & Shutdown

insert image description here
insert image description here

–3, Test

http://localhost:8080/

insert image description here

3. Tomcat directory structure

–1, core directory

D:\Java\apache-tomcat-8.5.72\bin: The directory where the executable files in the tomcat server are stored
D:\Java\apache-tomcat-8.5.72\conf: The directory where the configuration files in the tomcat server are stored
D:\Java\apache-tomcat-8.5.72\lib: stores the jar packages that the tomcat server depends on when running
D:\Java\apache-tomcat-8.5.72\logs: The directory where the log files generated by the Tomcat server are stored when it is running, recording some information about each startup and shutdown
D:\Java\apache-tomcat-8.5.72\temp: The directory for temporary files generated by the tomcat server. Tomcat will clean up this directory by itself, so you can ignore this directory.
D:\Java\apache-tomcat-8.5.72\work: stores the working files generated by the tomcat server
D:\Java\apache-tomcat-8.5.72\webapps: This is the default directory managed by the localhost virtual host. Your developed project code must be in the webapps directory before you can access your program through a browser, including various resources (html, css, js, jsp, servlet, pictures, etc.) and directories.
D:\Java\apache-tomcat-8.5.72\conf\server.xml: stores the core configuration of the tomcat server, including the host, port number, etc.
D:\Java\apache-tomcat-8.5.72\webapps\ROOT\WEB-INF\web.xml: You can configure the homepage of an application and other information

–2, change the default port number to 8080

Tomcat software uses port 8080 by default, but you can also customize the port number to what you need.

insert image description here
insert image description here

4. Access your own project resources

–1, add your own simple project in webapps

insert image description here
insert image description here

–2, Test

insert image description here

–3, a complete web application structure

You also need to create some file structures, which is not necessary if you use the development tool. The tool will automatically create these structures.

insert image description here

WEB-INF directory: Resource files placed in this directory are protected and cannot be directly accessed by the browser
classes directory, used to store compiled class files
lib directory, used to store jar packages that web applications depend on
web.xml file, used to store some configuration information related to the Web application (this file can be left unconfigured, but once created, it must be filled with content, otherwise an error will be reported)

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  version="3.1">
  
</web-app>

5. Integrate Tomcat in IDEA

–1, the operation is as shown below

insert image description here
insert image description here
insert image description here

–2, Test

If there are resources in the server, you can test it directly. Rules: http://localhost:port number/project name/resource name Example: http://localhost:8080/test/studentform.html

This is the end of this article about the super detailed tutorial on getting started with Tomcat server. For more relevant Tomcat server content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed tutorial on installing Tomcat8.5 in Centos8.2 cloud server environment
  • Alibaba Cloud Server Tomcat cannot be accessed
  • Solution to slow response of Tomcat server
  • Detailed steps for configuring Tomcat server in IDEA 2020
  • Detailed steps for installing JDK and Tomcat on Linux cloud server (recommended)

<<:  Introduction to major browsers and their kernels

>>:  MySQL InnoDB transaction lock source code analysis

Recommend

Several ways to use v-bind binding with Class and Style in Vue

Adding/removing classes to elements is a very com...

MySQL free installation version configuration tutorial

This article shares the MySQL free installation c...

Solution to 404 Problem of Tomcat Installation in Docker

Find the containerID of tomcat and enter the toma...

How to deploy MySQL and Redis services using Docker

Table of contents How to deploy MySQL service usi...

Research on Web Page Size

<br />According to statistics, the average s...

CSS3 uses animation attributes to achieve cool effects (recommended)

animation-name animation name, can have multiple ...

7 interview questions about JS this, how many can you answer correctly

Preface In JavaScript, this is the function calli...

Illustration of the process of using FileZilla to connect to the FTP server

When I first started setting up an ftp server on ...

dl, dt, dd list label examples

The dd and dt tags are used for lists. We usually...

How to install Odoo12 development environment on Windows 10

Preface Since many friends say they don’t have Ma...

Tutorial on logging into MySQL after installing Mysql 5.7.17

The installation of mysql-5.7.17 is introduced be...

How to deploy code-server using docker

Pull the image # docker pull codercom/code-server...

Multiple ways to calculate age by birthday in MySQL

I didn't use MySQL very often before, and I w...