When using Web server Tomcat for Web deployment, you need to configure the Web services directory of the server without using other ides. This article lists several ways that Tomcat can configure the Web services directory.

The premise

Ensure that Tomcat is installed successfully. If you do not know whether the installation is successful, perform the following operations to check the Web service directory configuration

Enter localhost: 8080 in the address box of the browser. If the following page is displayed, the installation is successful.

Ps: Before entering the url, open Tomcat*. Exe in the bin file in the Tomcat installation directory.

If the page shown in the preceding figure cannot be displayed, the default Tomcat port may be occupied. You can modify the default Tomcat port or stop the process that occupies the port.

To change the port, go to Tomcat installation path →conf→server. XML, find the code snippet shown in the following figure, and change the port number in the red box.

If Tomcat starts and blinds, you are advised to refer to the super Tomcat Startup and Blinds on CSDN.

Method of configuring a Web service catalog

Web service root

The ROOT directory of the Tomcat Web service is Tomcat installation path \webapps\ROOT. If you put the JSP file in this directory, you can directly enter localhost:8080/ file name in the browser to open the JSP page. The following figure

Set the Web service directory under Webapps

Any subdirectory in the Webapps directory of the Tomcat server installation directory can be used as a Web service directory. We can create a new subdirectory under Webapps, which becomes the Web services directory. Put the JSP file into this directory, and open the JSP page by typing “localhost:8080/ subdirectory name/JSP file name” in the browser.

If the name of the new subdirectory is test, the following figure is displayed

Create a Web service catalog

We can also set up any directory on our computer except the Webapps directory as a Web services directory and specify a virtual directory for the Web services directory (to hide the actual location of the Web services directory and to open JSP pages only by accessing the virtual directory).

The following describes how to set a virtual directory

Open sever. XML in conf folder of Tomcat installation directory and find the code section at the end of the file. Add the following code before

<Context path = "/virtual" docBase = "D:\\test" debug = "0" reloadable = "true"/>
Copy the code

Where path is the name of the self-selected virtual directory and docBase is the path of the real folder to be set as the Web service directory.

After adding the code to save, can in the browser input “localhost: 8080 / virtual/hello.html JSP” access to the JSP page.

PS: Don’t forget to restart Tomcat*.exe before entering

In addition, you can create a subdirectory under the Web service directory and add the full path of the subdirectory after the path of the Web service directory when searching in the browser.

As in the Web service called virtual directory new subdirectories v1, JSP file to be included in the v1, can be in the browser input “localhost: 8080 / virtual/v1 / hello. JSP” access to the page.