Tomcat context. xml

Source: Internet
Author: User

1. Before Tomcat 5.5:

---------------------------------------------------------------

Context is the <context> element in the host in/CONF/server. XML, which is defined by the context interface. Each <context element represents a single web application executed on the VM.

XML

    <Context path="/kaka" docBase="kaka" debug="0" reloadbale="true">  

1> path: the virtual folder to be created. Note that it is/Kaka. It specifies the URL entry of the Web application to be asked by the consumer, such as http: // localhost: 8080/Kaka /****
2> docbase: Location of the actual folder on the hard disk (path of the application or the path where the war file is stored)
3> reloadable: assuming this property is set to true, atatserver monitors changes in the class files in the WEB-INF/classes and web-INF/lib folders during execution, if a class file is monitored to be updated, the server automatically loads the web application again, so that we can change the application without restarting tomcat.

A host element contains multiple context elements. The path of each context must be unique and defined by the path attribute. In addition, you must define a context with Path = "". This context is called the default web application of the VM to process requests that cannot match the context path regardless of the context.

 

 

2. After Tomcat 5.5:

---------------------------------------------------------------

It is not recommended to configure Server. XML, but to configure it independently in/CONF/context. xml. Server. XML is a resource that cannot be dynamically reloaded. Once the server is started, you have to restart the server to load the file again. The context. xml file is not used, and the Tomcat server regularly scans the file. Once the file is changed (the timestamp is changed), the file is automatically loaded again without restarting the server.

XML

<Context Path = "/Kaka" docbase = "Kaka" DEBUG = "0" reloadbale = "true" privileged = "true"> <watchedresource> WEB-INF/web. XML WEB-INF/Kaka. XML </watchedresource> monitors the resource file, assuming that the web. XML | Kaka. if the XML changes, you will take the initiative to load and modify the application again. <Resource Name = "JDBC/testsiteds" indicates the specified JNDI name auth = "Container" indicates the authentication method, generally containertype = "javax. SQL. datasource "maxactive =" 100 "Maximum number of connections supported by the connection pool maxidle =" 30 "Maximum number of connections in the connection pool maxidle connections maxwait =" 10000 "when the connection pool is used up, new request wait time. millisecond username = "root" indicates database Username Password = "root" indicates database username driverclassname = "com. mySQL. JDBC. driver "indicates JDBC driverurl =" JDBC: mysql: // localhost: 3306/testsite "/> indicates the URL of the database </context>

Appendix: Three scopes of context. xml:

1. Tomcat server level:

Configure in/CONF/context. xml

2. Host level:

Add in/CONF/Catalina/$ {hostname? Context. XML, and then configure

3. web app level:

Add in/CONF/Catalina/$ {hostname? $ {Webappname}. XML, and then configure

The server. XML Element in Tomcat


Tomcat context. xml

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.