Configuring Jndi in Tomcat

Source: Internet
Author: User

1. server.xml configuration file for Tomcat

Added in the <Host> tab of the Tomcat configuration file conf/server.xml file <Context> labels can mark the current Web Application , the application is loaded with the system boot, such as:

<context            path= ""            docbase= "E:\TestPro\WebRoot"            reloadable= "true" >      </Context>

This is said that the path property is marked as empty, access to the system without adding the project name, can be directly accessed, development and debugging more convenient. <Context>represents a run on<Host>on the individualWebapplication, a<Host>can have multiple<Context>elements, eachWebthe application must have a uniqueURLpath, thisURLPath in<Context>the properties inPathset in.  

    <Context> elements of eachPropertiesthe meaning: 
    1)Path:Specifies the URL entry to access the Web app .  
    2)docBase:Specifies the file path for the Web app, either given an absolute path or given a relative path to the appBase Property relative to <Host> , if the Web app is in an open directory structure, specify the Web app's root directory, if the Web app is a War file, specify The path to the war file.  
    3)reloadable:If this property is set to true, TomcatThe server monitors changes to class files in the web-inf/classes and web-inf/lib directories while running. If a class file is detected to be updated, the server will automatically reload the Web app.  

2. Configuring JNDI in Tomcat

If you are using JNDIin development, there are two ways to put database information into a container for hosting:

1) add <Resource> tag in conf/server.xml

<context            path= ""            docbase= "E:\TestPro\WebRoot"            reloadable= "true" > <resource name= "dbtest" Auth= "Container"  type= "Javax.sql.DataSource" driverclassname= "Oracle.jdbc.driver.OracleDriver" url= "  JDBC:ORACLE:THIN:@192.168.16.23:1521:ORCL "  username=" test "password=" 1234 "maxactive=" "maxidle=  " maxwait= "-1"/></context>

2) add <Resource> tag in conf/context.xml

Similar to the above, the contents of the Resource tag are added to the context tab

The difference between the two approaches is that the first is valid only for the application that corresponds to the current Context, and the second is valid for all applications in the entire container.

3. invoking JNDI in Java

/span>

Configuring Jndi in Tomcat

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.