Deployment of the Tomcat web app and mapping of the site Directory __web

Source: Internet
Author: User
Tags tomcat

Note: $CATALINA _base represents a directory of Tomcat installations, and you will see later
The first half is analysis, the second part is the actual combat

CATALINA--A nice name: Catalina

What is the deployment of a web app and the mapping of a site directory? That's just how to get users to the website we're developing.

It is well known that I do a good job of the site is placed on a server of a certain hard disk in a file,

For example, I developed a Web site that was placed under the XXX server's E:\MyWeb folder

Now I want people to access my site, how to do it?

Detailed instructions are given in the help documentation for Tomcat 6.0.36,

After you've installed Tomcat, open the following address and you'll see the document.

Http://localhost:8080/docs/config/context.html

For information on how to deploy Web apps and map site directories, Tomcat reads as follows

for Tomcat 6, unlike Tomcat 4.x, it isn't recommended to place <Context> elements directly in the Server.xml fi Le. This was because it makes modifying theContext configuration More invasive since the main conf/server.xml file can Not being reloaded without restarting Tomcat.

Context Elements may explicitly defined:in the $CATALINA _base/conf/context.xml file:the context element information would be Loaded by all WebApps. In the $CATALINA _base/conf/[enginename]/[hostname]/context.xml.default file:the context element information'll be Loaded by all webapps of that host. In individual files (with a ". xml" extension) in the $CATALINA _base/conf/[enginename]/[hostname]/directory. The name of the file (less the. xml extension) would be used as the context path. Multi-level context paths May is defined using #, e.g. Foo#bar.xml for a context path Of/foo/bar. The default Web application may is defined by using a file calledroot.xml. Only if a context file does not exist for the application in the $CATALINA _base/conf/[enginename]/[hostname]/, in an indiv Idual file At/meta-inf/context.xml inside the application files. If the Web application is packaged as a WAR then/meta-inf/context.xml would be copied to $CATALINA _base/conf/[enginename]/[ hostname]/and renamed to MatCH The application ' s context path. Once This file exists, it'll not being replaced if a new WAR with a newer/meta-inf/context.xml are placed in the host ' s AppB Ase. Inside a Host element in the Mainconf/server.xml.

With the exception of server.xml, files, define Context elements could only define a singleContext ele ment.

From the above we know that Tomcat gives us 5 ways to configure the Web application, and here I'm talking about the third,

Simple and practical, no need to restart Tomcat
The original translation is as follows


In an archive file with an. xml extension, the XML file is spoken.
In individual files (with a ". xml" extension)


The localhost folder under the Tomcat installation directory
As my D:\Tomcat\Tomcat6.0.36\conf\Catalina\localhost.
In the $CATALINA _base/conf/[enginename]/[hostname]/directory.


The file name removes the. xml suffix that will be used as the path to the web App
What is the context path? For example, I am ok.xml on the localhost file, and OK is the context path.
The user opens the Web page in the form of http://XXX:8080/ok/123.html
Note: The Ok.xml is equipped with 123.html path, such as <context docbase= "E:\Web"/>
123.html in the E:\Web.
The name of the file (less the. xml extension) would be used as the context path.

The multilevel path is defined by the # number, at which time the file name is in the form Aaa#bbb#ccc.xml
Access in the form of http://XXX:8080/aaa/bbb/ccc/123.html
Multi-level context paths may be defined using #,
e.g. Foo#bar.xml for a context path Of/foo/bar.


Define the default Web page app to create a root.xml file
Don't forget to set the path to the site in Root.xml.
The default Web application is defined by using a file called Root.xml.


//Actual combat part

1) My test page is placed under E:\MyWeb, screenshot below

2) Tomcat installed in D:\Tomcat\Tomcat6.0.36 screenshot below


3) Enter the localhost directory D:\Tomcat\Tomcat6.0.36\conf\Catalina\localhost
Build file Ok.xml content in localhost directory <context docbase= "E:\MyWeb"/>
Screenshot below

4) Start Tomcat and access http://localhost:8080/ok/hello.html

And a simple way to access Web apps
Copy the entire directory of our web app to the WebApps folder in the Tomcat installation directory
If you copy MyWeb to WebApps
Then launch Tomcat access http://localhost:8080/MyWeb/hello.html to

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.