How to configure Tomcat and run your first Java Web project on IntelliJ IDEA 2018

How to configure Tomcat and run your first Java Web project on IntelliJ IDEA 2018

1 Download and start Tomcat

Go to the official website http://tomcat.apache.org/ and download the latest version of Tomcat 9

insert image description here

Download according to your computer version, I am using Windows 64-bit

insert image description here

After downloading, just unzip it.
Find the directory you unzipped, open the /bin directory under the folder, where startup.bat starts tomcat and shutdown.bat shuts down tomcat

insert image description here

After double-clicking startup.bat to start tomcat, open http://localhost:8080. If you enter the following interface, it means that the startup is successful.

insert image description here

2 Configure environment variables for Tomcat 9 in win10

Right-click "My Computer", click "Properties", select "Advanced System Variables"

insert image description here

Select the Advanced tab -> Environment Variables

insert image description here

In "System Variables", add system variables and add the following:
Create a new variable name: CATALINA_BASE
Variable value: E:\SoftWares\tomcat9\apache-tomcat-9.0.8 //Copy the tomcat decompression directory on your own computer

Create a new variable name: CATALINA_HOME
Variable value: E:\SoftWares\tomcat9\apache-tomcat-9.0.8 //Copy the tomcat decompression directory on your own computer

Click OK.
Then edit and modify the variable values ​​​​of CLASSPATH and Path.
Add the following to the ClassPath variable value: %CATALINA_HOME%\lib\servlet-api.jar; (note that you need to add the English “;” after the original variable value)
Add the following to the Path variable value: %CATALINA_HOME%\bin;%CATALINA_HOME%\lib (note that you need to add the English “;” after the original variable value)
Just click OK.

insert image description here

Finally, verify whether the configuration is successful.
Use the keyboard win+R to enter cmd, enter the startup command, if the following picture appears, it means the configuration is successful.

insert image description here

3 Create the first JavaWeb project in IDEA

Click File -> New -> Project…

insert image description here

Select Java -> Web Application, then click Next.

insert image description here

Give a project name, here we take JavaWebTest as an example, and then click Finish.

insert image description here

The project directory structure is as follows:

insert image description here

Modify the code in index.jsp to facilitate testing later. The code is as follows:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
 <head>
 <title>$Title$</title>
 </head>
 <body>
 Hello world!
 </body>
</html>

4 Configure Tomcat and run the project on IntelliJ IDEA 2018

Open IDEA and click Run-Edit Configurations…

insert image description here

Click the "+" sign, then find Tomcat Server and select Local

insert image description here

Under the Tomcat Server -> Unnamed -> Server -> Application server project, click Configuration, find the local Tomcat server (that is, the decompression path above), and then click the OK button. You can change Unnamed to another name, such as Tomcat 9

insert image description here

Then go to the Deployment tab next to it, click the "+" sign, select Artifact, select the project name

insert image description here

As shown in the figure below, you can also modify the name of the Application context path to make it simpler, and then click OK.

insert image description here

After configuration, you can see the following picture on the project interface and click Run.

insert image description here

Operation Results

insert image description here

Summarize

This is the end of this article about configuring Tomcat on IntelliJ IDEA 2018 and running the first JavaWeb project. For more information about configuring Tomcat on IntelliJ IDEA 2018 and running the first JavaWeb project, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • JavaWeb Getting Started: Creating a Web Project, Configuring Tomcat with Idea
  • Java Web Development [Tomcat Environment Configuration] MyEclipse+IDEA Configuration Tutorial
  • Create a Maven Javaweb project in idea and configure it (graphic tutorial)
  • Solve the mysql8.0.15 configuration problem of javaweb in idea
  • IDEA 2021 configuration JavaWeb project super detailed tutorial

<<:  js realizes the non-select drop-down box version of the three-level linkage of provinces, cities and districts

>>:  Detailed steps for configuring mysql8.0.20 with binlog2sql and simple backup and recovery

Recommend

Building a Redis cluster on Docker

Table of contents 1. Pull the image 2. Create a R...

MySQL 5.7.21 Installer Installation Graphic Tutorial under Windows 10

Install MySQL and keep a note. I don’t know if it...

How to use limit_req_zone in Nginx to limit the access to the same IP

Nginx can use the limit_req_zone directive of the...

How to implement remote automatic backup of MongoDB in Linux

Preface After reading the previous article about ...

How to solve the abnormal error ERROR: 2002 in mysql

Recently, an error occurred while starting MySQL....

How to support Webdings fonts in Firefox

Firefox, Opera and other browsers do not support W...

Vue front-end development auxiliary function state management detailed example

Table of contents mapState mapGetters mapMutation...

Summary of JavaScript Timer Types

Table of contents 1.setInterval() 2.setTimeout() ...

Summary of MySQL ALTER command knowledge points

When we need to change the table name or modify t...

Summary of CSS counter and content

The content property was introduced as early as C...

Detailed explanation of MySql 5.7.17 free installation configuration tutorial

1. Download the mysql-5.7.17-winx64.zip installat...

VMware Workstation 15 Pro Installation Guide (for Beginners)

01. VMware Workstation Pro 15 Download Download: ...

Detailed explanation of JavaScript onblur and onfocus events

In HTML pages, visual elements such as buttons an...