This article mainly summarizes the Tomcat deployment and release of JSP applicationsProgramThree methods
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:
<Host name = "localhost" DEBUG = "0" appbase = "webapps" unpackwars = "true" autodeloy = "true" xmlvalidation = "falase" xmlnamespaceaware = "false">
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.
<Context Path = "/MyApp" reloadable = "true" docbase = "D: \ MyApp" workdir = "D: \ MyApp \ work"/>
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:
<Context Path = "/admin" docbase = "$ {Catalina. Home}/Server/webapps/admin" DEBUG = "0" privileged = "true"> </context>
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 be loaded according to the configuration...