Tomcat Configuring Web virtual maps and configuring virtual hosts
There are three ways to configure the Web Virtual Map folder, such as the following:
First ( to restart the server ):
Open the Server.xml file under the path Tomcat 6.0\conf,
Add a line above the </Host> of the file content? A statement : <context path= "" docbase= "here point to the folder you want to map for example (E:\code\news)" reloadable= "true"/ >, Notice the changes to restart the server and then visit http://localhost:8000/test.html in the browser (test.html is the file stored in the E:\code\news folder, If you change to path path= "/hello", then visit http://localhost:8000/hello/test.html on your browser.
Note : Let's say path= "/hello" note to have a backslash '/'
reloadable= "true" after the source program to save a bit, and actively restart the server, and change the JSP file, do not need to restart the server
Second ( no need to restart the server):
create an XML file under the folder path: \tomcat 6.0\conf\catalina\localhost (for example,
A.xml) file contents: <context docbase= "Here point to the folder you want to map for example (E:\code\news
) "/> Then visit the browser http://localhost:8000/a/test.html
Note : test.html is a file stored in the E:\code\news folder;
Assuming that the Catalina directory cannot be found under the Conf directory, copy the Catalina directory under \tomcat 6.0\work to the \tomcat 6.0\conf file.
Third (throw the folder folder directly under the WebApps folder, which is also the simplest, without restarting the server):
Method 1. Throw the folder folder directly under the WebApps folder
Method 2. Packaging the directory into a war file is still in the WebApps directory, this is very convenient, in such a way to send the file to the customer is also common, the directory is packaged into a war file : First open the directory path you want to package in the DOC environment analogy: note the last other point "."
To configure a virtual host:
If you want to configure a virtual host on your computer for example: www.google.com;
You can access your local server's resources by entering www.google.com in your browser.
actions such as the following :
If you create a Google directory on the E drive and there is a new1 directory, New1 directory has a a.html file and a web-inf directory, the Web-inf directory has a Web. xml file ( This file is a.html as the home page ),
The contents of the Web. xml file are:
[HTML]View Plaincopy
- <? XML version="1.0" encoding="iso-8859-1" ?>
- < Web-app xmlns="Http://java.sun.com/xml/ns/javaee"
- Xmlns:xsi = "Http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemalocation = "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- version = "2.5" >
- < welcome-file-list >
- < Welcome-file > a.html </ Welcome-file >
- </ welcome-file-list >
- </ Web-app >
In fact, this file is the end of the Web. xml file in the Tomcat 6.0\conf folder .
then, in the Tomcat 6.0\conf folder, add the Server.xml file to this program, which is placed on top of </Engine> ; Remember to change the port number 8080 into a server.xml file:
[HTML]View Plaincopy
- < Host name="www.google.com" appBase=" E:\google " >
- < Context path="" docBase="E:\google\news1" />
- </ Host >
And then add it in the Hosts file? IP and www.google.com of the host
Hosts file under the C:\WINDOWS\system32\drivers\etc folder, the host's IP generally you open the Hosts file there will be displayed, for example: 127.0.0.1 www.google.com
Finally, visit www.google.com on the browser to see the contents of the a.html file. ( Note To restart the server)
Tomcat Configuring Web virtual maps and configuring virtual hosts