Tomcat deployment Project approach summary and three ways to deploy Web projects

Source: Internet
Author: User

methods for three deployment projects in Tomcat

The Tomcat default project directory is WebApps, which is equivalent to the Web root of IIS, and there are several ways to configure the project (remember to restart Tomcat when configured):

Way One, create a directory directly under WebApps, such as you want to build a project on http://localhost:8080/FristProject/access, you can directly in this directory to create Fristproject folder;

Mode two, create an XML document under WebApps, if you want to build fristproject this project, you can build fristproject.xml in this directory, and then edit this document as follows:

<context path= "/fristproject" docbase= "E:\javaweb" ebug= "0" privileged= "true" ></Context>

Path= "" You want to access the path to the project on http://localhost:8080, written here/fristproject is to visit the project on Http://localhost:8080/FristProject.
Docbase= "" Place the local path to your project document, written in E:\javaweb (this directory should already exist before you restart Tomcat);

mode three, edit the Conf/server.xml under Tomcat's installation directory, find
<!--Tomcat Root context-->
<!--<context path= "" docbase= "ROOT" debug= "0"/>-->
......
<!--start my frist project-->
<context path= "/fristproject" docbase= "E:\javaweb" ebug= "0" privileged= "true" ></Context>
<!--stop my frist project-->
</Host>
......
The above configuration is very simple, a lot of parameters are not written, we suggest that you look at the configuration of tomcat files, such as errors pointed to the file, the default home page, etc., here is not introduced.
After you restart Tomcat you can create a index.html file in your local path (the directory docbase points to), and look at the http://localhost:8080/FristProject/ Index.html can be opened, if the normal browsing, the explanation is no problem.


How to summarize Tomcat deployment projects

I. Deployment Modalities

1, three simple ways to deploy:

(1) Direct project deployment from IDE integrated development environment (Eclipse MyEclipse) to Tomcat specific steps see Web projects in eclipse automatically deployed to Tomcat

(2), the war package is the deployment of your project into a war package directly copied to the Tomcat default loading directory, generally not modified words are under the WebApps, that is, conf/servlet/host appbase refers to this directory.

(3), copy the project to the ComCat default loading directory WebApps, this and IDE integrated deployment is the same.

2, two kinds of flexible deployment methods:

(1), configure conf/servlet/, add a context in the servlet file host: <context docbase= "test" path= "/test" reloadable= "true" source= " Org.eclipse.jst.jee.server:test "/>

Docbase refers to the physical road strength of your project, and path refers to the path that the browser accesses, such as: Http://localhost:18080/test test is the value of this path. Note here that docbase this path, you have to point to the directory that holds the classes file of your compiled code, and if it's just your project, it must be in this directory format: test/web-inf/classes, because Tomcat What the container wants is your compiled executable code.

Configuration instance:

<context docbase= "D:\Javaee\project\testresin\webapp" path= "/testresin" true "reloadable=" Org.eclipse.jst.jee.server:test "/>

DocBase looks different from the previous one because when you create a project using Eclipse, the classes file is stored under WebApp, so docBase is no longer a simple project name but refers to the web-inf/classes directory, path is the access path to the project: http://localhost:18080/testresin/


(2), this configuration is the most flexible, is also recommended for such a deployment of the \conf\catalina\localhost path under the new file. xml:
Create an. xml file in the localhost directory and configure the same as the servlet, docBase refers to the physical path of your project.

<context docbase= "test" path= "/test" reloadable = "false"/>


The value of path in this setting is not the name of the project and the name of the project. You can set it casually, but be aware that the. xml file name cannot be duplicated, the name of the file is the address that the browser accesses


Configuration instance: this instance and 2 (1) are the two configurations of the same project, and below you will see their differences:

To create an. xml file:



Configure. xml file: <context docbase= "D:\Javaee\project\testresin\webapp" path= "reloadable=" true "source=" Org.eclipse.jst.jee.server:test "/>


Browser Access Path


Summary: From this example we can see that the same project Testresin is created under the servlet and localhost. The two configurations of XML, DocBase are all the same, point to the physical path of the project, and note that the directory where classes is located is Web-inf, while path in the servlet is accessed by the browser and created under localhost. The path value of this configuration of XML can be arbitrarily valued, and the project name and browser access address are not related, and file name is the road to browser access, if you do not want to see the name of your project can use this way to the individual name.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.