preface

Tomcat server is a free open source Web application server, belongs to lightweight application server, in small and medium-sized systems and concurrent access users are not many occasions is widely used, is the first choice for developing and debugging JSP programs. For starters, you can assume that when the Apache server is configured on a machine, you can use it to respond to requests for HTML (an application in standard Common Markup Language) pages. Tomcat is actually an extension of the Apache server, but at runtime it runs on its own, so when you run Tomcat, it actually runs as a separate process from Apache. The trick is that, when configured correctly, Apache serves HTML pages, while Tomcat actually runs JSP pages and servlets. In addition, Tomcat, like Web servers such as IIS, has the ability to process HTML pages, and it is also a Servlet and JSP container. A separate Servlet container is the default mode of Tomcat. However, Tomcat does not handle static HTML as well as the Apache server.

Tomcat is simply a web server running JAVA. At the bottom is a Socket program. It is also a container for JSP and Serlvet.

First, the basic environment

1. Program architecture

C/S(client/server) : Advantages: Part of the code is written on the client, providing good user experience. Disadvantages: When the server is updated, the client also needs to be updated, occupying large browser/server resources. Advantages: As long as the client has a browser on the line, occupy resources minor disadvantages: user experience is relatively speaking, the experience is not so goodCopy the code

2, server: a computer, better than the general configuration

3. Prerequisites: Ensure that the JDK is installed on your computer. (Java –version) check the JDK version (7.0 or above, the current JDK version is JDk1.8.0_162)

3, the web server software: dealing with the client’s request, return | information resources, the client input address in the browser’s address bar, then the web server receives the request, and then the response message

4, Web application: need server support, common Web server: Tomcat (Apache), webLogic(Oracle), WebPHere (IBM), IIS (Microsoft)

Second, the installation

For Windows, Tomcat provides two installation files :exe and ZIP.

Exe is a runnable installation program, just double-click the file to start installing Tomcat. During the installation process, the installation program will automatically search for the location of JDK and JRE, and add the Tomcat service to the Windows operating system service, and add the Tomcat server management menu from “Start” to “Programs” (easy to install, but not suitable for this version of the upgrade).

② Zip is a compressed package, just need to decompress it to the local hard disk, this method is suitable for Windows installation, also suitable for other operating systems (Linux) (recommended, can install multiple versions).

The following demonstrates zip installation:

1, enter the website to download the installer: tomcat.apache.org/download-90…

2, after the completion of the download, there has been no next step

3. Verify the installation

To test this, open your browser and type http://localhost:8080 or http://127.0.0.1:8080 in the address bar

The installation is successful!

3. Introduction to tomcat directory

Open tomcat’s decompressed directory and you can see the following directory structure:

Bin: stores binary executable files in this directory. These files fall into two main categories: those ending in.sh (Linux commands) and those ending in.bat (Windows commands). And many environment variables are set here, such as JDK path, tomcat path, etc. Conf: Stores tomcat configuration files. Lib: stores jar packages that need to be loaded when Tomcat is running. Logs: Stores log files generated during Tomcat running, especially logs output on the console. In Windows, logs generated on the console are stored in the catalina.xxxx-xx-xx.log file. In Linux, logs generated on the console are stored in the catalina.xxxx-xx-xx.log file. Webapps: a directory for storing Web projects. Each folder contains a project. If directories already exist under this file, they are tomcat's own. Note: ROOT is a special project, which corresponds to ROOT if the project directory is not given in the address bar. Work: Used to store compiled files of Tomcat at runtime, such as JSP compiled files. To clear the cache, clear the work directory and restart Tomcat.Copy the code

4. How to publish a project to Tomcat (how to let other computers access resources on my computer)

The first way:

Under webapps: Copy files to root under webapps and access them directly in your browser. Create a new folder under webapps and place the resources you want to access in itCopy the code

The second way:

Configure the virtual path: in the server. XML file in the CONF, configure the virtual path in the Context tag under the host tag

Conf /server. XML. Add virtual path configuration. 3Copy the code

The third way:

Configuring a Virtual Path

1, in tomcat/conf/catalina/localhost/folder to create a new XML file, define your own name

2. Add the configuration by writing the context element to the file contents

3. Access it in a browser

5. Idea Configure Tomcat

Click on the Run – EDit Configurations

Click the “+” sign on the left to find the Tomcat Server– Local

Under Tomcat Server -> Unnamed -> Server -> Application Server, click Configuration to find your local Tomcat Server and click the OK button.

IntelliJ IDEA Tomcat configuration is complete.