search
HomeJavajavaTutorialHow to implement Tomcat deployment of web projects?

How to implement Tomcat deployment of web projects?

Jun 25, 2017 am 10:43 AM
tomcatwebdetaileddeployproject

Reading instructions: The article is based on Tomcat8. If there are differences in other versions, please identify them yourself. This article is an original article by the blogger and may not be reproduced without permission.

Without any IDE, here are three ways to manually deploy web projects in Tomcat:

1. Deploy the unpacked webapp directory

2. Packaged war file

3.Manager Web application

1: Deploy the unpacked webapp directory

Deploy the web project to One of the methods in Tomcat is to deploy web projects that are not encapsulated in WAR files. To use this method to deploy an unpackaged webapp directory, just put our project (compiled release project, non-development project) in Tomcat's webapps directory. As shown in the figure below:

#At this time, open the Tomcat server (make sure the server is open), and you can access our project in the browser, as shown in the figure below:

But at this time, we found that when accessing our project content, we must add our project name "myweb", which is not good. If we want to access directly in the form of http://localhost:8080/index.html without adding the project name, as follows:

We find that a 404 error occurs. If we want to have normal access to our project through the above connection, we can edit conf/server.xml to configure it.

Open the server.xml file and find the Host element. The default configuration is as follows:

We need to add the content of Context inside the Host. After adding it, it is as follows:

At this time, you can access it through http://localhost:8080/index.html without adding a project name. As follows:

(In fact, it can still be accessed through the address http://localhost:8080/myweb/index.html at this time.)

2: Packaged war file

In this way, you only need to place the packaged war file in the webapps directory. As shown in the figure below:

When we start Tomcat, the first thing Tomcat needs to do is to unpack the contents of the war file into a path with the same file name. Remove the .war extension and read the project files from the unpacked directory. Now, we start Tomcat, as shown in the following figure:

You can see that there is an unpacked myweb folder in the webapps directory. Then you can access it in the browser through the address http://localhost:8080/myweb/index.html. If we want to access with the address http://localhost:8080/index.html, we also need to configure the server.xml file. The operation steps are the same as above and will not be repeated.

Three: Manager Web method

The Manager Web source application allows us to manage our own Web projects through the Web. Of course, things get a little trickier if anyone can manage everyone else's projects, let alone security. Therefore, when we want to manage our own projects through Manager Web, we need to set permissions.

First visit the Apache Tomcat welcome page (it should be noted that if the project files in the webapps/ROOT directory are overwritten by our own projects developed and deployed in the IDE, the welcome page may not be accessible).

At this time, when we click on the circled part in the picture, we will be prompted to enter the user name and password. So we need to add roles in the conf/tomcat-users.xml file. Tomcat-users.xml does not add any roles by default. Because we want to manage our project through Manager Web, we add the manager-gui role in it. As follows (the part in the circle is the role we added, just fill in the username, password, and roles in the manager-gui above):

After configuring this, restart the server , you can enter the management interface.

Enter the Server Status page to view the status of the server and see Tomcat related information, including Tomcat version, JVM version, JVM provider, etc., as shown below:

Enter the Manager App page to manage our projects. The page is as shown below:

Applications shows the project directory under the webapps directory: ROOT directory, doc directory, manager directory, these are all included with Tomcat. We don’t have any projects of our own at this time. Now we start deploying our project. Under Deploy, we see two ways: 1. Deploy directory or WAR file located on server; 2. WAR file to deploy.

First demonstrate the method of deploying through WAR file.

myweb.war is our packaged project file. Click "Select File" to select our project file on our host. This file can be placed in any location. If it is placed under webapps, Tomcat will decompress it directly when starting Tomcat. If placed in another location, when starting Tomcat, Tomcat will copy the myweb.war file to the webapps directory and then decompress it. Select the file and click Deploy to publish it. At this time, you can access it through http://localhost:8080/myweb/index.html in the browser.

At this time, let’s take a look at the changes in the Manager App page. The circled part in the picture below has the myweb project we just released.

The next step is to deploy directory or WAR file located on server. Copy myweb.war to the webapps directory, fill in \myweb after WAR or Directory URL:, and click Deploy to publish.

The above is the detailed content of How to implement Tomcat deployment of web projects?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How does platform independence benefit enterprise-level Java applications?How does platform independence benefit enterprise-level Java applications?May 03, 2025 am 12:23 AM

Java is widely used in enterprise-level applications because of its platform independence. 1) Platform independence is implemented through Java virtual machine (JVM), so that the code can run on any platform that supports Java. 2) It simplifies cross-platform deployment and development processes, providing greater flexibility and scalability. 3) However, it is necessary to pay attention to performance differences and third-party library compatibility and adopt best practices such as using pure Java code and cross-platform testing.

What role does Java play in the development of IoT (Internet of Things) devices, considering platform independence?What role does Java play in the development of IoT (Internet of Things) devices, considering platform independence?May 03, 2025 am 12:22 AM

JavaplaysasignificantroleinIoTduetoitsplatformindependence.1)Itallowscodetobewrittenonceandrunonvariousdevices.2)Java'secosystemprovidesusefullibrariesforIoT.3)ItssecurityfeaturesenhanceIoTsystemsafety.However,developersmustaddressmemoryandstartuptim

Describe a scenario where you encountered a platform-specific issue in Java and how you resolved it.Describe a scenario where you encountered a platform-specific issue in Java and how you resolved it.May 03, 2025 am 12:21 AM

ThesolutiontohandlefilepathsacrossWindowsandLinuxinJavaistousePaths.get()fromthejava.nio.filepackage.1)UsePaths.get()withSystem.getProperty("user.dir")andtherelativepathtoconstructthefilepath.2)ConverttheresultingPathobjecttoaFileobjectifne

What are the benefits of Java's platform independence for developers?What are the benefits of Java's platform independence for developers?May 03, 2025 am 12:15 AM

Java'splatformindependenceissignificantbecauseitallowsdeveloperstowritecodeonceandrunitonanyplatformwithaJVM.This"writeonce,runanywhere"(WORA)approachoffers:1)Cross-platformcompatibility,enablingdeploymentacrossdifferentOSwithoutissues;2)Re

What are the advantages of using Java for web applications that need to run on different servers?What are the advantages of using Java for web applications that need to run on different servers?May 03, 2025 am 12:13 AM

Java is suitable for developing cross-server web applications. 1) Java's "write once, run everywhere" philosophy makes its code run on any platform that supports JVM. 2) Java has a rich ecosystem, including tools such as Spring and Hibernate, to simplify the development process. 3) Java performs excellently in performance and security, providing efficient memory management and strong security guarantees.

How does the JVM contribute to Java's 'write once, run anywhere' (WORA) capability?How does the JVM contribute to Java's 'write once, run anywhere' (WORA) capability?May 02, 2025 am 12:25 AM

JVM implements the WORA features of Java through bytecode interpretation, platform-independent APIs and dynamic class loading: 1. Bytecode is interpreted as machine code to ensure cross-platform operation; 2. Standard API abstract operating system differences; 3. Classes are loaded dynamically at runtime to ensure consistency.

How do newer versions of Java address platform-specific issues?How do newer versions of Java address platform-specific issues?May 02, 2025 am 12:18 AM

The latest version of Java effectively solves platform-specific problems through JVM optimization, standard library improvements and third-party library support. 1) JVM optimization, such as Java11's ZGC improves garbage collection performance. 2) Standard library improvements, such as Java9's module system reducing platform-related problems. 3) Third-party libraries provide platform-optimized versions, such as OpenCV.

Explain the process of bytecode verification performed by the JVM.Explain the process of bytecode verification performed by the JVM.May 02, 2025 am 12:18 AM

The JVM's bytecode verification process includes four key steps: 1) Check whether the class file format complies with the specifications, 2) Verify the validity and correctness of the bytecode instructions, 3) Perform data flow analysis to ensure type safety, and 4) Balancing the thoroughness and performance of verification. Through these steps, the JVM ensures that only secure, correct bytecode is executed, thereby protecting the integrity and security of the program.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool