Four ways to deploy Tomcat in Web applications

Source: Internet
Author: User

There are four ways to deploy Web apps in Tomcat, with a brief summary of:

(1) Automatic deployment with Tomcat

(2) Deploy with the console

(3) Add a custom Web Deployment file (%tomcat_home%\conf\catalina\localhost\appname.xml)

(4) Manually modify the %tomcat_home%\conf\server.xml file to deploy the Web App

The first way: Use Tomcat to deploy automatically

Using the Tomcat auto-deployment approach is the simplest and most common way. If a Web application structure is d:\workspace\webapp\appname\web-inf\*, simply throw the webcontent level AppName of a Web application directly into the % Tomcat_home%\webapps folder, the system deploys the Web app directly to Tomcat. So don't repeat it here.

second way: Deploy with the console

If a WEB application structure is d:\workspace\webapp\appname\web-inf\*, deployment using the console is as follows: Enter the deploy area of the Tomcat Manager console-- Type "XXX" in the context path (optionally named)--in the war or Directory URL: type D:\workspace\WebApp\AppName (means to find a web app under this path)-- Click the Deploy button.

Then under the %tomcat_home%\webapps path will automatically appear a folder called XXX, the contents of which is the content of D:\workspace\WebApp\AppName , Just the name is xxx (this is the result of typing XXX in the context path earlier).

The essence of deployment using the console is still the automatic deployment of Tomcat.

Third Way: Increase your custom Web deployment file

If a WEB application structure is d:\workspace\webapp\appname\web-inf\*, this kind of deployment is a little bit more complicated, we need to %tomcat_home%\conf Create a new folder under the path catalina--then create a new localhost folder in it--and then create a new XML file that adds a two-tier directory and a new XML file:%tomcat_home%\conf\catalina\ Localhost\web application configuration file. xml, which is the configuration file that deploys the Web app. For example, we create a new %tomcat_home%\conf\catalina\localhost\xxx.xml, which has the following contents:

<context path= "/xxx" reloadable= "true" docbase= "D:\workspace\WebApp\AppName" workdir= "D:\workspace\WebApp\work" />

Attention:

(1) The Workdir in the above code indicates the working directory that the Web app is deployed in (where the servlet compiled by the JSP in the Web app can be found), and if you use eclipse as the IDE, Generally can be artificially set in the work directory of WebApp.

If Workdiris not indicated in the custom Web Deployment file Xxx.xml, the Web app will be deployed by default in %tomcat_home%\work\catalina\localhost\ Under the path under the new folder named XXX. (The JSP compiled in the Web app can be found in the servlet)

(2)Context path Specifies the virtual path name of the Web App. docBase Specifies the source path of the Web app to be deployed.

Fourth Way: Manually modify the%tomcat_home%\conf\server.xml file to deploy the Web App

This method opens the %tomcat_home%\conf\server.xml file and adds the following elements to it:

<context docbase= "D:\workspace\WebApp\AppName" path= "/xxx" debug= "0" reloadable= "false"/>

Then start Tomcat.

via:http://blog.csdn.net/titilover/article/details/6822258

Four ways to deploy Tomcat in Web applications

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.