Tomcat web application deployment)

Source: Internet
Author: User
Tags file url

The following describes how to deploy a web application using Tomcat:

Tomcat automatic deployment

Copy the petweb directory to $ catalina_home \ webapps, and then start the server. This method is relatively simple, but Web Applications Program Must be in the webapps directory. The access address is as follows: http: // localhost: 8080/petweb/
Modify server. xml file deployment

Use ue or editplus to open the configuration file of tomcat in CONF/server. xml and find the following content:

    host   name  =" localhost "  debug  =" 0 "  appbase  =" webapps "  unpackwars  =" true "  autodeploy  =" true "  xmlvalidation  =" false"   xmlnamespaceaware  =" false"  >  .....     host  > 

Add the following content between hosts:

 
<ContextPath= "/Mywebapps"Reloadable= "True"Docbase= "D: \ mywebapps"Workdir= "D: \ mywebapps \ EMP"/>

Path: indicates the access path. In the preceding example, the access to this application is http: // localhost: 8080/mywebapps.
Reloadable: indicates that class packages can be automatically loaded under the classes and Lib folders at runtime.
Docbase: the address of the application. Note that the direction of the slash is "\".
Workdir: the address where the cached files are stored.
 

Add a custom context deployment File

In the tomcat installation directory conf \ Catalina \ localhost, there are three built-in Tomcat applications, copy an XML file at will, and modify docbase to point to your own application, and rename the path. For more information about the parameters, see the three methods. Or you can create a new MyApp. XML (note that the file name will be used as the path in the context, no matter how the path is set in the file is invalid), copy the following content and modify the corresponding path.

 
<ContextPath= "/Test"Docbase= "F:/J2EE/yazd_war_3_0"Debug= "0"Privileged= "True"Reloadable= "True" ></Context>

After the deployment is complete, access through http: // localhost: 8080/MyApp.

 

Deploy Web applications through Tomcat web application manager

 LoginTomcatConsole:Http: // localhost: 8080/, Enter the user name and password to manage and dynamically publish the application.

InContext path (option ):Input/MyApp, Which indicates the access address of your application.

XML configration File URLTo specifyXMLFile, for exampleF :\CreateHmcx. xmlFile, the content is as follows:

 
 <ContextReloadable= "False" />

WhereDocbaseYou do not need to write it because it is entered in the next text box.

Or simply, this text box is left empty.War or directory URL:TypeF: \ hmcxAnd then clickDeployButton.WebThe Application name isContext path (option ):MyApp.

If you deploy. WarThere is also a simpler way to file, and there isSelect war file uploaeClick Browse to select. WarFile, and then clickDeployOr.

 

Web application display directory

Tomcat accesses the project by default and does not display the project files and directories. This function is required during project development.

You can add it to the Web. xml file.

 <  Servlet  >      <  Servlet-name  > Default </ Servlet-name  >      <  Servlet-class  > Org. Apache. Catalina. servlets. DefaultServlet </  Servlet-class  >      <  Init-Param  >          <  Param-name  > Debug </ Param-name  >          <  Param-Value  > 0 </  Param-Value  >      </  Init-Param  >      <  Init-Param  >          <  Param-name  > Listings </  Param-name  >          <  Param-Value  > True </  Param-Value  >      </  Init-Param  >      <  Load-on-startup  > 1 </ Load-on-startup  >  </  Servlet  > 

If the project development is complete and you are ready to deploy it on the server, remember to take the web in step 3. change the value of the listings parameter in the XML file to false, so that the deployment path of the project cannot be displayed to the user!

Change the value of listings to true and restart tomcat. The test is successful after the URL is entered!

 

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.