Method 1: In the conf directory of tomcat. add: & lt; Contextpath & quot;/hello & quot; docBase & quot; D: eclipse3.2.2forwebtoolsworkspacehelloWebRoot & quot; deb to the & lt; host/& gt; node in xml
Method 1: In the conf directory of tomcat, in server. xml, Add:
</Context>
For details about the Context node attributes, see the relevant documentation.
Method 2: Copy the web project file to the webapps directory.
Method 3: Flexible. in the conf Directory, create a new Catalina (case sensitive) \ localhost directory and create an xml file in the directory. The name can be obtained at will, the content of the xml file is as follows:
</Context>
The 3rd methods have the advantage of defining aliases. The project running on the server is named path, and the URL accessed externally uses the XML file name. This method can easily hide the project name. some project names are fixed and cannot be changed. However, it is very effective to change the path for external access.
2nd and 3 also have advantages. you can define some personalized configurations, such as data source configurations.
There is also a detailed article
This section describes three methods for deploying and releasing JSP applications in Tomcat.
1. directly put it in the Webapps Directory
The Webapps directory of Tomcat is the default application directory of Tomcat. when the server starts, all applications under this directory will be loaded. You can also package the JSP program into a war package and place it in the directory. the server will automatically unbind the war package and generate a folder with the same name under this directory. A war package is a jar package with a special format. it compresses all the content of a Web program. You can use IDE environments of many development tools, such as Eclipse, NetBeans, ant, and JBuilder. You can also run the cmd command: jar-cvf applicationname. war package .*;
You can even package in program execution:
Try {
String strjavahome = system. getproperty ("java. home ");
Strjavahome = strjavahome. substring (0, strjavahome. lastindexof (\) + "\ bin \\";
Runtime.getruntime(cmd.exe c ("cmd/c start" + strjavahome + "jar cvf hello. war c: \ tomcat5.0 \ webapps \ root \\*");
}
Catch (exception e) {system. out. println (e );}
The default application directory webapps can also be changed. Open the server. xml file in the conf directory of Tomcat and find the following content:
2. specify
In the Tomcat configuration file, a Web application is a specific Context. you can deploy a JSP application in the new Context in server. xml. Open the server. xml file and create a Context in the Host tag. the content is as follows.
Here, path is the virtual path, docBase is the physical path of the JSP application, workDir is the working directory of the application, and the files generated for running the application are stored.
3. create a Context file
After the Web application is loaded by the server, an XML file is generated in the conf \ catalina \ localhost directory of Tomcat. the content of the XML file is as follows:
It can be seen that the Context information of an application is described in the file. its content is consistent with the Context information format in server. xml, and the file name is the virtual directory name. You can directly create an xml file and place it in the conf \ catalina \ localhost directory of Tomcat. Example:
Note: to delete a Web application, you also need to delete the corresponding Context in the server. xml folder under webapps, and set the conf
Delete the xml file in the \ catalina \ localhost directory. Otherwise, Tomcat will still be loaded with the shore configuration...