Environment:
1. Database: Microsoft SQL Server 2000
2. Database driver: Net.sourceforge.jtds.jdbc.Driver
JNDI (Java naming and Directory Interface) Overview:
TOMCAT4 (5) provides a Jndi--initialcontext implementation instance that is compatible with the Java Enterprise Edition application service. Its initial data is set in the $catalina_home/conf/server.xml file and may be referenced by the following elements in the Web application Environment Description (/web-inf/web.xml):
1 <env-entry>--Environment Entry, set how the application operates.
2 <resource-ref>--resource parameters, generally is the database driver, JavaMail session, custom class factory and so on.
3) <resource-env-ref>--is used in servlet 2.4 to simplify the setting of resource resources such as environment parameters and RESOURCE-REF variables that do not require authentication information.
InitialContext is set up when Web application initialization is used to support Web page application components. All the portals and resources are placed in the java:comp/env section of the Jndi namespace. Click on the following URL to get more information:
1 Java Naming and catalog interface (Java naming and directory Interface)
2) Java Platform Description (Java Platform specification)
Setting Jndi Resources
To set the Jndi resource, use the following markers in the $catalina_home/conf/server.xml file:
1) <environment>--sets the name and value of the variable Jndi initialcontext entry in the domain (as stated above <env-entry> equivalence).
2) <resource>--sets the name and type of the resources available to the application (as stated above <resource-ref> equivalence).
3) <resourceparams>--set the name of the Java Resource class factory or the JavaBean attribute to be used.
4) <resourcelink>--adds a link to the global Jndi environment (Jndi context).
These markers must be placed between <Context> and </Context> (for specialized web applications) or between <DefaultContext> and </DefaultContext>.
In addition, the names and values located in the Web Application Environment description (Web application descriptor) (/web-inf/web.xml) are also set in the initial environment (Initial context) when the <Environemt> The initial value is reset when the element value is allowed.
Global variables can be set in <GlobalNamingResources> of <Server> child elements.