From 6efee31f42bc2b007008d85a6e34428eb2f59b99 Mon Sep 17 00:00:00 2001
From: markt /WEB-INF/web.xml file to reference resources; resources
-referenced in these elements must be defined in an application-server-specific configuration.
+referenced in these elements must be defined in an application-server-specific
+configuration.
For Tomcat 6, these entries in per-web-application
InitialContext are configured in the
-<Context> elements that can be specified
-in either $CATALINA_HOME/conf/server.xml or, preferably,
-the per-web-application context XML file (either META-INF/context.xml).
+<Context> elements that
+can be specified in either $CATALINA_HOME/conf/server.xml or,
+preferably, the per-web-application context XML file (
+META-INF/context.xml).
Tomcat 6 maintains a separate namespace of global resources for the @@ -103,9 +105,8 @@ conn.close(); for JNDI, and for the features supported by Java2 Enterprise Edition (J2EE) servers, which Tomcat emulates for the services that it provides:
Each available JNDI Resource is configured based on inclusion of the
-following elements in the <Context> or
-<DefaultContext> elements:
<Context> element:
<Context> or
Any number of these elements may be nested inside a -<Context> element (to be associated -only with that particular web application).
+<Context> element (to be
+associated only with that particular web application).
In addition, the names and values of all <env-entry>
elements included in the web application deployment descriptor
(/WEB-INF/web.xml) are configured into the initial context as
-well, overriding corresponding values from conf/server.xml
+well, overriding corresponding values from the
+<Context> element
only if allowed by the corresponding
-<Environment> element (by setting the
-override attribute to "true").
<Environment> element (by setting the override
+attribute to "true").
Global resources can be defined in the server-wide JNDI context, by adding the resource elements described above to the @@ -170,10 +172,11 @@ include it in the per-web-application context.
Tomcat 6 includes a series of standard resource factories that can
provide services to your web applications, but give you configuration
- flexibility (in $CATALINA_HOME/conf/server.xml) without
- modifying the web application or the deployment descriptor. Each
- subsection below details the configuration and usage of the standard
- resource factories.
<Context> element)
+ without modifying the web application or the deployment descriptor. Each
+ subsection below details the configuration and usage of the standard resource
+ factories.
See Adding Custom Resource Factories for information about how to create, install, @@ -280,9 +283,10 @@ writer.println("foo = " + bean.getFoo() + ", bar = " +
To configure Tomcat's resource factory, add an elements like this to the
- $CATALINA_HOME/conf/server.xml file, nested inside the
- Context element for this web application.
To configure Tomcat's resource factory, add an element like this to the
+ <Context> element for
+ this web application.
Tomcat 6 includes a standard resource factory that will create
javax.mail.Session session instances for you, already
- connected to the SMTP server that is configured in server.xml.
+ configured to connect to an SMTP server.
In this way, the application is totally insulated from changes in the
email server configuration environment - it simply asks for, and receives,
a preconfigured session whenever needed.
Note that the application uses the same resource reference name
that was declared in the web application deployment descriptor. This
- is matched up against the resource factory that is configured in
- $CATALINA_HOME/conf/server.xml, as described below.
<Context> element
+ for the web application as described below.
To configure Tomcat's resource factory, add an elements like this to the
- $CATALINA_HOME/conf/server.xml file, nested inside the
- Context element for this web application.
<Context> element for
+ this web application.
+
/WEB-INF/classes/SendMailServlet.java.
- WARNING - The default configuration assumes that
- there is an SMTP server listing on port 25 on localhost.
- If this is not the case, edit the
- $CATALINA_HOME/conf/server.xml file, and modify the
- parameter value for the mail.smtp.host parameter to be
- the host name of an SMTP server on your network.
WARNING - The default configuration assumes that there
+ is an SMTP server listing on port 25 on localhost. If this is
+ not the case, edit the
+ <Context> element for
+ this web application and modify the parameter value for the
+ mail.smtp.host parameter to be the host name of an SMTP server
+ on your network.
NOTE - The default data source support in Tomcat
is based on the DBCP connection pool from the
- Jakarta Commons
- subproject. However, it is possible to use any other connection pool
+ Commons
+ project. However, it is possible to use any other connection pool
that implements javax.sql.DataSource, by writing your
own custom resource factory, as described
below.
Note that the application uses the same resource reference name
- that was declared in the web application deployment descriptor. This
- is matched up against the resource factory that is configured in
- $CATALINA_HOME/conf/server.xml, as described below.
Note that the application uses the same resource reference name that was
+ declared in the web application deployment descriptor. This is matched up
+ against the resource factory that is configured in the
+ <Context> element for
+ the web application as described below.
To configure Tomcat's resource factory, add an element like this to the
- /META-INF/context.xml file in the web application.
<Context> element for
+ the web application.
+
If none of the standard resource factories meet your needs, you can
- write your own factory and integrate it into Tomcat 6, and then configure
- the use of this factory in the conf/server.xml configuration
- file. In the example below, we will create a factory that only knows how
- to create com.mycompany.MyBean beans, from the
- Generic JavaBean Resources
- example, above.
If none of the standard resource factories meet your needs, you can write
+ your own factory and integrate it into Tomcat 6, and then configure the use
+ of this factory in the
+ <Context> element for
+ the web application. In the example below, we will create a factory that only
+ knows how to create com.mycompany.MyBean beans from the
+ Generic JavaBean Resources example
+ above.
javax.naming.Reference, which contains the class name
- of this factory class, as well as the configuration properties
- (from conf/server.xml) to use in creating objects
- to be returned.javax.naming.Reference, which contains the class name of
+ this factory class, as well as the configuration properties (from the
+ <Context> for the
+ web application) to use in creating objects to be returned.
nameCtx, or null if no name
is specified.To configure Tomcat's resource factory, add an elements like this to the
- $CATALINA_HOME/conf/server.xml file, nested inside the
- Context element for this web application.
<Context> element for
+ this web application.
+