Tomcat6 version virtual directory detail configuration

Source: Internet
Author: User
Tags root directory tomcat

In the TOMCAT6 version:

One
1, "Official document" I do not recommend.
Found in the tomcat\conf under the Server.xml.
Unpackwars= "true" autodeploy= "true"
Xmlvalidation= "false" Xmlnamespaceaware= "false" >
</Host>
In which to add:
<context path= "" docbase= "to Your Path" reloadable= "true" ></Context>
The docbase of this will be changed to your project directory.
2, do not modify the Server.xml "recommended use of this method"
Create a new XML file under the Conf "Catalina" localhost of the Tomcat folder (for the Tomcat6 version and above, the two folders that need to be created Catalina and localhost themselves). Content is
<?xml version= "1.0" encoding= "UTF-8"?>
<context
docbase=, "Change your path."
Reloadable= "true" >
</Context>
File name change to your own example Http://localhost:8080/bbs, the filename is Bbs.xml

Other configurations:
Open the Tomcat6.0 "conf" Web.xml file and find:
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
Set False to True save, reboot Tomcat, let tomcat6 support file list display

Two

Tomcat6.0 virtual directory configuration [turn]
Set the virtual directory "site" through Http://localhost:8080/site access to the physical path D: "Site folder contents." The setup process is as follows:
1. Copy the Web-inf folder in the Tomcat6.0 "WebApps" root directory to the D: "Site Directory."
2. Open the Web.xml file in the Web-inf directory of D: "Site" and add after </description>:
<!--jspc servlet mappings Start-->
<!--jspc servlet mappings End-->
3. Open Tomcat6.0 "conf" Server.xml file, add between <Host> and </Host>:
<context path= "/site" docbase= "D:" Site "></Context>
Path= "/site" is the name of the virtual directory
Docbase= "D: Site" > For physical path
4. Open the Tomcat6.0 "conf" Web.xml file and find:
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
Set false to True to save, restart Tomcat, and now you can apply the Http://localhost:8080/site virtual directory.

Tomcat6 the method of setting the virtual directory without modifying the Server.xml


In the Conf "Catalina" localhost of the Tomcat folder (for the Tomcat6 version and above, you need to create Catalina and localhost these two folders)

Increase the project. xml file (the file name project is the same as the XXX for the following "path="/xxx "")

File contents:

<context path= "/project" reloadable= "true" docbase= "E:" Javastudio "OOB" workdir= "E:" Javastudio "OOB" work "/>


Docbase is the upper-level directory of the Web-inf folder for the project folder
Workdir refers to the Tomcat resolution JSP converted to Java files, and compiled into Class folder, set in the project folder, you can avoid porting to other places to read the JSP file for the first time need to be resolved again. General Format: project folder "work
Reloadable means that you can reload, generally set to true, easy to use, and do not need to restart Tomcat frequently.

Start Tomcat later and access it in the browser input http://localhost:8080/project
The welcome file for the project.

Go: TomCat 6.0 virtual directory configuration. March 09, 2008 Sunday 13:51 to configure the virtual directory under 5.0, I generally use in the Conf "Server.xml to add <context .../> method, but this method in 6.0 failure (after the verification of the effective, It may have been a mistake in the course of the experiment. Follow the instructions for the relevant documentation after Tomcat 6.0 startup, and try some of the methods: http://localhost:8080/docs/config/context.html

-----------------------------a description of the context in the tomcat6.0 document-------------------
Your may define as many context elements as for you wish. Each such context must have a is a unique context path. In addition, a context must is present with a context path equal to a zero-length string. This context becomes the "Default Web application for" virtual host, and is used to process all requests the does not MA Tch any other context ' s context path.

For Tomcat 6, unlike Tomcat 4.x, it isn't recommended to place <Context> elements directly in the Server.xml file. This is because it makes modifing the context configuration more invasive since the main conf/server.xml file cannot to be re Loaded without restarting Tomcat.


Context elements may explicitly defined:

In the $CATALINA _home/conf/context.xml file:the context element information would be loaded by all WebApps
in the $ Catalina_home/conf/[enginename]/[hostname]/context.xml.default File:The Context element information'll is loaded by All WebApps of this host
in individual files (with a ". xml" extension) in the $CATALINA _home/conf/[enginename]/[hostna me]/directory. The name of the file (less the. xml) extension is used as the context path. Multi-level context paths may defined using #, e.g. Context#path.xml. The default Web application may is defined by using a file called Root.xml.
If the previous file is not found to this application, in a individual file at/meta-inf/context.xml inside the AP plication files
inside a Host element in the main conf/server.xml
---------------------------------------------- ---------------------------------

Each verification, the method 1,2 is invalid, the success of the following 2: (below%tomcat% to represent the Tomcat6.0 installation directory, you want to access the browser through the http://localhost:8080/abc/default.jsp D: "myjsp" DEFAULT.JSP)

Method One: (the document says it is not recommended)

Find%tomcat% "conf" Server.xml, before </Host> add:
<context docbase= "D:" myjsp "path="/abc "/>
After you save the file, restart Tomcat. Note: The case can not be wrong! The direction of the oblique rod "/" or "" is not mistaken.

Method Two: This method is recommended to use, relatively simple.

In the%tomcat% "Conf Catalina" Locahost (the directory may need to be created manually), create a new file Abc.xml, note that the ABC in the filename indicates the name of the virtual directory, so it is not optional, the contents of the file is:
<context docbase= "D:" myjsp "/>
Restart Tomcat.

-------------------------------------------------------------------------------------------
Other setting: Whether to list the switch settings for all files in the related directory when the filename is not explicitly specified in the URL:

Open the%tomcat% "conf" Web.xml file and find:
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
Change False to True.

-------------------------------------------------------------------------------------------
Other people's similar experience: http://fengzhiyu-sh.javaeye.com/blog/153506 experience no need to set the text in the Web application under the Web.xml file.

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.