Tomcat configuration on the local machine

Unpack the

After the Tomcat package is decompressed, the installation is complete

  • /bin: a script file stored in Windows (.bat) and Linux(.sh).
  • /conf: The configuration file, the most important of which is server.xml (configuration Servlet)
  • /lib: stores jar files accessible to Tomcat and all Web applications
  • /logs: Stores log files generated during Tomcat execution
  • /work: store the generated class file after JSP compilation
  • /webapps: Tomcat Web application directory

Configuring environment Variables

1. Configuration JAVA_HOME

Control Panel — System — View advanced System Settings — Environment Variables — System environment variables

New (W) — OK

2. Configuration JRE_HOME

3. Configure the CATALINA_HOME

 

run

Run CMD in E:\DevTols\apache-tomcat-9.0.30\bin

Type startup to start Tomecat

 

A dialog box is displayed, indicating that the service is successfully opened

Enter shutdown in CMD to shutdown Tomcat. If no exception is thrown, Tomcat is not completely shutdown. Run shutdown again until CMD throws an exception

No exception was thrown once

An exception is thrown and the closure is successful.

Configure Tomcat in IDEA

Configure Tomcat

File — Settings — Build, Execution, Deployment — Application Servers\

 

Click the + sign to add Tomcat Server

Select the Tomcat installation path and click OK to Apply.

 

Configuring the Tomcat Switch

Run — Edit Configurations sets the Name (which can be in Chinese). This Name is for the programmer to see, followed by the Name set for the server

Select Application Server, Open Browser Default is recommended, and click OK.

 

After the configuration is complete, the Tomcat button will appear in the low-end. Click Run to open Tomcat, but the website managed by Tomcat cannot be modified.

Tomcat can also be opened with DeBug, and the websites managed by Tomcat can be modified. Therefore, Tomcat is generally opened with DeBug.

 

Click DeBug and the website pops up. Tomcat starts successfully

 

IDEA to create a website

File — New — Module select Java EnterPrise and then Web Application

To rename the Module Name (English only), click Finash.

Web Creation succeeded

 

SRC stores the dynamic resource file

The Web hosts static resource files, JAR packages, and configuration files

Create a Directory in web-INF named lib to store the JAR package.

Click “+” in “File — project-structure — Modules” to import jar packages

 

If you want to import images to a website, add them in the web directory instead of the WEB-INF directory

At this point, the website has been created. You can start Tomcat.

A dialog box is displayed, indicating that the website has been created successfully

 

Setting the Default home Page

Add code to web.xml

<welcome-file-list> <welcome-file>/html/welcome.html</welcome-file> <! </welcome-file-list> </welcome-file-list>Copy the code

This opens the default screen