Tomcat Virtual directory settings

Source: Internet
Author: User
Tags auth

In the Tcomcat directory, the default configuration is to place the Web application in the WebApps directory. The default configuration. WebApps is like the root directory of a site. But If the site is a lot. If you put more, you will feel confused. So our situation here is to put the Web application in another place. But also to make the virtual directory of Tomcat.

Here are three ways to do this:

First: (Not recommended):

Change server.xml. Open the file in Notepad. Between <Host> and <context path= "/site" docbase= "C:/site" reloadable= "true" debug= "0" >
</Context>
Parameter: path represents entering Http://localhost:8080/site in the browser
Docbase represents the physical absolute path of your package, and the default relative path is $tomcat_home$/webapps

Second: (recommended, then and maintenance)

Directly in the $tomcat_home$/conf/catalina/localhost directory to write the configuration file, file name arbitrary, preferably with your Web application is the same easy to manage, such as site.xml content for
<context path= "/site" docbase= "C:/site" reloadable= "true" debug= "0" >
</Context>

Note: The above use is tomcat5.x,tomcat6.0/conf directory no longer have/catalina/localhost directory, but this method is still feasible, just put the context fragment file into the/conf directory can

Third: Change the entire root directory:

Find Unpackwars= "true" autodeploy= "true" >
Set the appbase to the desired path (absolute path)
Problems occurred: Input: http://localhost:8080/No default page appears
The reason for this is, of course, to change the path. The solution is to copy the document over, or to set the original default to the virtual path.

Configuring the JDBC Connection pool

Directly before us configure the <context path= "/site" docbase= "C:/site" reloadable= "true" debug= "0" in the virtual directory >
</Context>
Add the following content

<resource name= "Jdbc/mysqlds" auth= "Container" type= "Javax.sql.DataSource"
Maxactive= "maxidle=" maxwait= "10000"
Username= "Dbusername" password= "Dbpassword" driverclassname= "Com.mysql.jdbc.Driver"
Url= "jdbc:mysql://127.0.0.1:3306/dbname?autoreconnect=true&amp;useunicode=true&amp;characterencoding= gb2312 "/>

The entire configuration becomes as follows:

<context path= "/site" docbase= "C:/site" reloadable= "true" debug= "0" >

<resource name= "Jdbc/mysqlds" auth= "Container" type= "Javax.sql.DataSource"
Maxactive= "maxidle=" maxwait= "10000"
Username= "Dbusername" password= "Dbpasswrod" driverclassname= "Com.mysql.jdbc.Driver"
Url= "jdbc:mysql://127.0.0.1:3306/db?autoreconnect=true&amp;useunicode=true&amp;characterencoding= gb2312 "/>


</Context>

Depending on the actual situation you can change the above italic part.

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.