Summary of jsp project deployment in Apache Tomcat 5.5 -- publishing JSP applications

Source: Internet
Author: User
Tags apache tomcat
This article mainly summarizes 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:
<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 still be loaded with the shore configuration...

Related Article

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.