Tomcat virtual directory configuration method and principle

Source: Internet
Author: User

After Tomcat is installed, simply put your package under $tomcat_home$/webapps and you can use it directly. This will make the WebApps more and more large and need to set up the virtual directory:

1. Single app settings:
Add between <Host> and <context path= "/site" docbase= "D:\site" reloadable= "true" debug= "0" >
</Context>
Parameter: path means the Http://localhost:8080/site is entered in the browser
Docbase represents the physical absolute path of your package, and the default absolute path is $tomcat_home$/webapps
This setting will then generate a Site.xml file in the $tomcat_home$/conf/catalina/localhost directory, the content of which is the content just set.
2. By the previous we know that the corresponding configuration file will be generated in the $tomcat_home$/conf/catalina/localhost directory, so we can directly

$tomcat _home$/conf/catalina/localhost Directory write profile file name arbitrary, preferably with your Web application is the same ease of management, such as site.xml content ibid.
<context path= "/site" docbase= "D:\site" reloadable= "true" debug= "0" >
</Context>
3. Change the entire root directory:
Find Unpackwars= "true" autodeploy= "true" >
Set the appbase to the desired path (absolute path)
Problem: Input: http://localhost:8080/No default page appears
The cause of course is that the path was changed. The solution is also very simple, copy the file over, or set the original default to a virtual path.


Tomcat Virtual Host Configuration
The first step,
<context path= "" docbase= "." debug= "0"/>
</Host>
<context path= "" docbase= "." debug= "0"/>
</Host>
Step Two,
For Windows XP:
\windows\system32\drivers\etc\hosts, this file does not have an extension and can be created manually.
127.0.0.1 localhost
127.0.0.1 www.dykj.com
127.0.0.1 www.zhip.com



Example:
<context path= "/site" docbase= "F:\workspace\myjsp\WebRoot" reloadable= "true" debug= "0" ></Context>
Where F:\workspace\myjsp\WebRoot has two directories and a file Meta-inf and Web-inf and index.jsp files, Web-inf file contains classes and Lib and web. xml


I want to deploy the server in Tomcat 6, and I added the Server.xml

<context path= "/ext" docbase= "D:\ext"/>

Then launch tomcat with no error alerts and then enter Http://localhost:8080/ext

Display client 404 error

Tomcat virtual directory configuration method and principle

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.