[66] | 1 | <html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Apache Tomcat Configuration Reference - The Context Container</title><meta value="Craig R. McClanahan" name="author"><meta value="craigmcc@apache.org" name="email"></head><body vlink="#525D76" alink="#525D76" link="#525D76" text="#000000" bgcolor="#ffffff"><table cellspacing="0" width="100%" border="0"><!--PAGE HEADER--><tr><td><!--PROJECT LOGO--><a href="http://tomcat.apache.org/"><img border="0" alt=" |
---|
| 2 | The Apache Tomcat Servlet/JSP Container |
---|
| 3 | " align="right" src="../../images/tomcat.gif"></a></td><td><font face="arial,helvetica,sanserif"><h1>Apache Tomcat 6.0</h1></font></td><td><!--APACHE LOGO--><a href="http://www.apache.org/"><img border="0" alt="Apache Logo" align="right" src="../../images/asf-logo.gif"></a></td></tr></table><table cellspacing="4" width="100%" border="0"><!--HEADER SEPARATOR--><tr><td colspan="2"><hr size="1" noshade></td></tr><tr><!--RIGHT SIDE MAIN BODY--><td align="left" valign="top" width="80%"><table cellspacing="4" width="100%" border="0"><tr><td valign="top" align="left"><h1>Apache Tomcat Configuration Reference</h1><h2>The Context Container</h2></td><td nowrap="true" valign="top" align="right"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Introduction"><strong>Introduction</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 4 | |
---|
| 5 | <blockquote><em> |
---|
| 6 | <p>The description below uses the variable name $CATALINA_BASE to refer the |
---|
| 7 | base directory against which most relative paths are resolved. If you have |
---|
| 8 | not configured Tomcat 6 for multiple instances by setting a CATALINA_BASE |
---|
| 9 | directory, then $CATALINA_BASE will be set to the value of $CATALINA_HOME, |
---|
| 10 | the directory into which you have installed Tomcat 6.</p> |
---|
| 11 | </em></blockquote> |
---|
| 12 | |
---|
| 13 | <p>The <strong>Context</strong> element represents a <em>web |
---|
| 14 | application</em>, which is run within a particular virtual host. |
---|
| 15 | Each web application is based on a <em>Web Application Archive</em> |
---|
| 16 | (WAR) file, or a corresponding directory containing the corresponding |
---|
| 17 | unpacked contents, as described in the Servlet Specification (version |
---|
| 18 | 2.2 or later). For more information about web application archives, |
---|
| 19 | you can download the |
---|
| 20 | <a href="http://java.sun.com/products/servlet/download.html">Servlet |
---|
| 21 | Specification</a>, and review the Tomcat |
---|
| 22 | <a href="../../appdev/index.html">Application Developer's Guide</a>.</p> |
---|
| 23 | |
---|
| 24 | <p>The web application used to process each HTTP request is selected |
---|
| 25 | by Catalina based on matching the longest possible prefix of the |
---|
| 26 | Request URI against the <em>context path</em> of each defined Context. |
---|
| 27 | Once selected, that Context will select an appropriate servlet to |
---|
| 28 | process the incoming request, according to the servlet mappings defined |
---|
| 29 | in the <em>web application deployment descriptor</em> file (which MUST |
---|
| 30 | be located at <code>/WEB-INF/web.xml</code> within the web app's |
---|
| 31 | directory hierarchy).</p> |
---|
| 32 | |
---|
| 33 | <p>You may define as many <strong>Context</strong> elements as you |
---|
| 34 | wish. Each such Context MUST have a unique context path. In |
---|
| 35 | addition, a Context must be present with a context path equal to |
---|
| 36 | a zero-length string. This Context becomes the <em>default</em> |
---|
| 37 | web application for this virtual host, and is used to process all |
---|
| 38 | requests that do not match any other Context's context path.</p> |
---|
| 39 | |
---|
| 40 | <p><b>For Tomcat 6, unlike Tomcat 4.x, it is NOT recommended to place |
---|
| 41 | <Context> elements directly in the server.xml file.</b> This |
---|
| 42 | is because it makes modifing the <strong>Context</strong> configuration |
---|
| 43 | more invasive since the main <code>conf/server.xml</code> file cannot be |
---|
| 44 | reloaded without restarting Tomcat.</p> |
---|
| 45 | |
---|
| 46 | <p><strong>Context</strong> elements may be explicitly defined: |
---|
| 47 | <ul> |
---|
| 48 | <li>in the <code>$CATALINA_BASE/conf/context.xml</code> file: |
---|
| 49 | the Context element information will be loaded by all webapps</li> |
---|
| 50 | <li>in the |
---|
| 51 | <code>$CATALINA_BASE/conf/[enginename]/[hostname]/context.xml.default</code> |
---|
| 52 | file: the Context element information will be loaded by all webapps of that |
---|
| 53 | host</li> |
---|
| 54 | <li>in individual files (with a ".xml" extension) in the |
---|
| 55 | <code>$CATALINA_BASE/conf/[enginename]/[hostname]/</code> directory. |
---|
| 56 | The name of the file (less the .xml extension) will be used as the |
---|
| 57 | context path. Multi-level context paths may be defined using #, e.g. |
---|
| 58 | <code>context#path.xml</code>. The default web application may be defined |
---|
| 59 | by using a file called <code>ROOT.xml</code>.</li> |
---|
| 60 | <li>if the previous file was not found for this application, in an individual |
---|
| 61 | file at <code>/META-INF/context.xml</code> inside the application files</li> |
---|
| 62 | <li>inside a <a href="host.html">Host</a> element in the main |
---|
| 63 | <code>conf/server.xml</code></li> |
---|
| 64 | </ul> |
---|
| 65 | </p> |
---|
| 66 | |
---|
| 67 | <p>With the exception of server.xml, files that define <strong>Context |
---|
| 68 | </strong> elements may only define a single <strong>Context</strong> element. |
---|
| 69 | </p> |
---|
| 70 | |
---|
| 71 | <p>In addition to explicitly specified Context elements, there are |
---|
| 72 | several techniques by which Context elements can be created automatically |
---|
| 73 | for you. See <a href="host.html#Automatic Application Deployment"> |
---|
| 74 | Automatic Application Deployment</a> and |
---|
| 75 | <a href="host.html#User Web Applications">User Web Applications</a> |
---|
| 76 | for more information.</p> |
---|
| 77 | |
---|
| 78 | </blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Attributes"><strong>Attributes</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 79 | |
---|
| 80 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Common Attributes"><strong>Common Attributes</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 81 | |
---|
| 82 | <p>All implementations of <strong>Context</strong> |
---|
| 83 | support the following attributes:</p> |
---|
| 84 | |
---|
| 85 | <table cellpadding="5" border="1"><tr><th bgcolor="#023264" width="15%"><font color="#ffffff">Attribute</font></th><th bgcolor="#023264" width="85%"><font color="#ffffff">Description</font></th></tr><tr><td valign="center" align="left"><code>backgroundProcessorDelay</code></td><td valign="center" align="left"> |
---|
| 86 | <p>This value represents the delay in seconds between the |
---|
| 87 | invocation of the backgroundProcess method on this context and |
---|
| 88 | its child containers, including all wrappers. |
---|
| 89 | Child containers will not be invoked if their delay value is not |
---|
| 90 | negative (which would mean they are using their own processing |
---|
| 91 | thread). Setting this to a positive value will cause |
---|
| 92 | a thread to be spawn. After waiting the specified amount of time, |
---|
| 93 | the thread will invoke the backgroundProcess method on this host |
---|
| 94 | and all its child containers. A context will use background |
---|
| 95 | processing to perform session expiration and class monitoring for |
---|
| 96 | reloading. If not specified, the default value for this attribute is |
---|
| 97 | -1, which means the context will rely on the background processing |
---|
| 98 | thread of its parent host.</p> |
---|
| 99 | </td></tr><tr><td valign="center" align="left"><code>className</code></td><td valign="center" align="left"> |
---|
| 100 | <p>Java class name of the implementation to use. This class must |
---|
| 101 | implement the <code>org.apache.catalina.Context</code> interface. |
---|
| 102 | If not specified, the standard value (defined below) will be used.</p> |
---|
| 103 | </td></tr><tr><td valign="center" align="left"><code>cookies</code></td><td valign="center" align="left"> |
---|
| 104 | <p>Set to <code>true</code> if you want cookies to be used for |
---|
| 105 | session identifier communication if supported by the client (this |
---|
| 106 | is the default). Set to <code>false</code> if you want to disable |
---|
| 107 | the use of cookies for session identifier communication, and rely |
---|
| 108 | only on URL rewriting by the application.</p> |
---|
| 109 | </td></tr><tr><td valign="center" align="left"><code>crossContext</code></td><td valign="center" align="left"> |
---|
| 110 | <p>Set to <code>true</code> if you want calls within this application |
---|
| 111 | to <code>ServletContext.getContext()</code> to successfully return a |
---|
| 112 | request dispatcher for other web applications running on this virtual |
---|
| 113 | host. Set to <code>false</code> (the default) in security |
---|
| 114 | conscious environments, to make <code>getContext()</code> always |
---|
| 115 | return <code>null</code>.</p> |
---|
| 116 | </td></tr><tr><td valign="center" align="left"><strong><code>docBase</code></strong></td><td valign="center" align="left"> |
---|
| 117 | <p>The <em>Document Base</em> (also known as the <em>Context |
---|
| 118 | Root</em>) directory for this web application, or the pathname |
---|
| 119 | to the web application archive file (if this web application is |
---|
| 120 | being executed directly from the WAR file). You may specify |
---|
| 121 | an absolute pathname for this directory or WAR file, or a pathname |
---|
| 122 | that is relative to the <code>appBase</code> directory of the |
---|
| 123 | owning <a href="host.html">Host</a>.</p> |
---|
| 124 | <p>The value of this field must not be set when the Context is |
---|
| 125 | configured using a <code>META-INF/context.xml</code> file as it will be |
---|
| 126 | inferred by the automatic deployment process.</p> |
---|
| 127 | </td></tr><tr><td valign="center" align="left"><code>override</code></td><td valign="center" align="left"> |
---|
| 128 | <p>Set to <code>true</code> to have explicit settings in this |
---|
| 129 | Context element override any corresponding settings in the |
---|
| 130 | <a href="defaultcontext.html">DefaultContext</a> element associated |
---|
| 131 | with our owning <a href="host.html">Host</a>. By default, settings |
---|
| 132 | in the DefaultContext element will be used.</p> |
---|
| 133 | <p>If a symbolic link is used for docBase then changes to the |
---|
| 134 | symbolic link will only be effective after a Tomcat restart or |
---|
| 135 | by undeploying and redeploying the conext. A context reload is not |
---|
| 136 | sufficient.</p> |
---|
| 137 | </td></tr><tr><td valign="center" align="left"><code>privileged</code></td><td valign="center" align="left"> |
---|
| 138 | <p>Set to <code>true</code> to allow this context to use container |
---|
| 139 | servlets, like the manager servlet. Use of the <code>privileged</code> |
---|
| 140 | attribute will change the context's parent class loader to be the |
---|
| 141 | <em>Server</em> class loader rather than the <em>Shared</em> class |
---|
| 142 | loader. Note that in a default installation, the <em>Common</em> class |
---|
| 143 | loader is used for both the <em>Server</em> and the <em>Shared</em> |
---|
| 144 | class loaders.</p> |
---|
| 145 | </td></tr><tr><td valign="center" align="left"><code>path</code></td><td valign="center" align="left"> |
---|
| 146 | <p>The <em>context path</em> of this web application, which is |
---|
| 147 | matched against the beginning of each request URI to select the |
---|
| 148 | appropriate web application for processing. All of the context paths |
---|
| 149 | within a particular <a href="host.html">Host</a> must be unique. |
---|
| 150 | If you specify a context path of an empty string (""), you are |
---|
| 151 | defining the <em>default</em> web application for this Host, which |
---|
| 152 | will process all requests not assigned to other Contexts.</p> |
---|
| 153 | <p>The value of this field must not be set except when statically |
---|
| 154 | defining a Context in server.xml, as it will be inferred from the |
---|
| 155 | filenames used for either the .xml context file or the docBase.</p> |
---|
| 156 | </td></tr><tr><td valign="center" align="left"><code>reloadable</code></td><td valign="center" align="left"> |
---|
| 157 | <p>Set to <code>true</code> if you want Catalina to monitor classes in |
---|
| 158 | <code>/WEB-INF/classes/</code> and <code>/WEB-INF/lib</code> for |
---|
| 159 | changes, and automatically reload the web application if a change |
---|
| 160 | is detected. This feature is very useful during application |
---|
| 161 | development, but it requires significant runtime overhead and is |
---|
| 162 | not recommended for use on deployed production applications. That's |
---|
| 163 | why the default setting for this attribute is <i>false</i>. You |
---|
| 164 | can use the <a href="../../manager-howto.html">Manager</a> web |
---|
| 165 | application, however, to trigger reloads of deployed applications |
---|
| 166 | on demand.</p> |
---|
| 167 | </td></tr><tr><td valign="center" align="left"><code>wrapperClass</code></td><td valign="center" align="left"> |
---|
| 168 | <p>Java class name of the <code>org.apache.catalina.Wrapper</code> |
---|
| 169 | implementation class that will be used for servlets managed by this |
---|
| 170 | Context. If not specified, a standard default value will be used.</p> |
---|
| 171 | </td></tr></table> |
---|
| 172 | |
---|
| 173 | </blockquote></td></tr></table> |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Standard Implementation"><strong>Standard Implementation</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 177 | |
---|
| 178 | <p>The standard implementation of <strong>Context</strong> is |
---|
| 179 | <strong>org.apache.catalina.core.StandardContext</strong>. |
---|
| 180 | It supports the following additional attributes (in addition to the |
---|
| 181 | common attributes listed above):</p> |
---|
| 182 | |
---|
| 183 | <table cellpadding="5" border="1"><tr><th bgcolor="#023264" width="15%"><font color="#ffffff">Attribute</font></th><th bgcolor="#023264" width="85%"><font color="#ffffff">Description</font></th></tr><tr><td valign="center" align="left"><code>allowLinking</code></td><td valign="center" align="left"> |
---|
| 184 | <p>If the value of this flag is <code>true</code>, symlinks will be |
---|
| 185 | allowed inside the web application, pointing to resources outside the |
---|
| 186 | web application base path. If not specified, the default value |
---|
| 187 | of the flag is <code>false</code>.</p> |
---|
| 188 | <p><b>NOTE: This flag MUST NOT be set to true on the Windows platform |
---|
| 189 | (or any other OS which does not have a case sensitive filesystem), |
---|
| 190 | as it will disable case sensitivity checks, allowing JSP source code |
---|
| 191 | disclosure, among other security problems.</b></p> |
---|
| 192 | </td></tr><tr><td valign="center" align="left"><code>antiJARLocking</code></td><td valign="center" align="left"> |
---|
| 193 | <p>If true, the Tomcat classloader will take extra measures to avoid |
---|
| 194 | JAR file locking when resources are accessed inside JARs through URLs. |
---|
| 195 | This will impact startup time of applications, but could prove to be useful |
---|
| 196 | on platforms or configurations where file locking can occur. |
---|
| 197 | If not specified, the default value is <code>false</code>.</p> |
---|
| 198 | </td></tr><tr><td valign="center" align="left"><code>antiResourceLocking</code></td><td valign="center" align="left"> |
---|
| 199 | <p>If true, Tomcat will prevent any file locking. |
---|
| 200 | This will significantly impact startup time of applications, |
---|
| 201 | but allows full webapp hot deploy and undeploy on platforms |
---|
| 202 | or configurations where file locking can occur. |
---|
| 203 | If not specified, the default value is <code>false</code>.</p> |
---|
| 204 | |
---|
| 205 | <p>Please note that setting this to <code>true</code> has some side effects, |
---|
| 206 | including the disabling of JSP reloading in a running server: see |
---|
| 207 | <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=37668">Bugzilla 37668</a>. |
---|
| 208 | </p> |
---|
| 209 | |
---|
| 210 | <p> |
---|
| 211 | Please note that setting this flag to true in applications that are |
---|
| 212 | outside the appBase for the Host (the <code>webapps</code> directory |
---|
| 213 | by default) will cause the application to be |
---|
| 214 | <strong>deleted</strong> on Tomcat shutdown. You probably don't want to |
---|
| 215 | do this, so think twice before setting antiResourceLocking=true on a webapp |
---|
| 216 | that's outside the appBase for its Host. |
---|
| 217 | </p> |
---|
| 218 | </td></tr><tr><td valign="center" align="left"><code>cacheMaxSize</code></td><td valign="center" align="left"> |
---|
| 219 | <p>Maximum size of the static resource cache in kilobytes. |
---|
| 220 | If not specified, the default value is <code>10240</code> |
---|
| 221 | (10 megabytes).</p> |
---|
| 222 | </td></tr><tr><td valign="center" align="left"><code>cacheTTL</code></td><td valign="center" align="left"> |
---|
| 223 | <p>Amount of time in milliseconds between cache entries revalidation. |
---|
| 224 | If not specified, the default value is <code>5000</code> |
---|
| 225 | (5 seconds).</p> |
---|
| 226 | </td></tr><tr><td valign="center" align="left"><code>cachingAllowed</code></td><td valign="center" align="left"> |
---|
| 227 | <p>If the value of this flag is <code>true</code>, the cache for static |
---|
| 228 | resources will be used. If not specified, the default value |
---|
| 229 | of the flag is <code>true</code>.</p> |
---|
| 230 | </td></tr><tr><td valign="center" align="left"><code>caseSensitive</code></td><td valign="center" align="left"> |
---|
| 231 | <p>If the value of this flag is <code>true</code>, all case sensitivity |
---|
| 232 | checks will be disabled. If not |
---|
| 233 | specified, the default value of the flag is <code>true</code>.</p> |
---|
| 234 | <p><b>NOTE: This flag MUST NOT be set to false on the Windows platform |
---|
| 235 | (or any other OS which does not have a case sensitive filesystem), |
---|
| 236 | as it will disable case sensitivity checks, allowing JSP source code |
---|
| 237 | disclosure, among other security problems.</b></p> |
---|
| 238 | </td></tr><tr><td valign="center" align="left"><code>processTlds</code></td><td valign="center" align="left"> |
---|
| 239 | <p>Whether the context should process TLDs on startup. The default |
---|
| 240 | is true. The false setting is intended for special cases |
---|
| 241 | that know in advance TLDs are not part of the webapp.</p> |
---|
| 242 | </td></tr><tr><td valign="center" align="left"><code>swallowOutput</code></td><td valign="center" align="left"> |
---|
| 243 | <p>If the value of this flag is <code>true</code>, the bytes output to |
---|
| 244 | System.out and System.err by the web application will be redirected to |
---|
| 245 | the web application logger. If not specified, the default value |
---|
| 246 | of the flag is <code>false</code>.</p> |
---|
| 247 | </td></tr><tr><td valign="center" align="left"><code>tldNamespaceAware</code></td><td valign="center" align="left"> |
---|
| 248 | <p>If the value of this flag is <code>true</code>, the TLD files |
---|
| 249 | XML validation will be namespace-aware. If you turn this flag on, |
---|
| 250 | you should probably also turn <code>tldValidation</code> on. The |
---|
| 251 | default value for this flag is <code>false</code>, and setting it |
---|
| 252 | to true will incur a performance penalty. |
---|
| 253 | </p> |
---|
| 254 | </td></tr><tr><td valign="center" align="left"><code>tldValidation</code></td><td valign="center" align="left"> |
---|
| 255 | <p>If the value of this flag is <code>true</code>, the TLD files |
---|
| 256 | will be XML validated on context startup. The default value for |
---|
| 257 | this flag is <code>false</code>, and setting it to true will incur |
---|
| 258 | a performance penalty.</p> |
---|
| 259 | </td></tr><tr><td valign="center" align="left"><code>unloadDelay</code></td><td valign="center" align="left"> |
---|
| 260 | <p>Amount of ms that the container will wait for servlets to unload. |
---|
| 261 | If not specified, the default value of the flag is <code>2000</code> |
---|
| 262 | ms.</p> |
---|
| 263 | </td></tr><tr><td valign="center" align="left"><code>unpackWAR</code></td><td valign="center" align="left"> |
---|
| 264 | <p>If true, Tomcat will unpack all compressed web applications before |
---|
| 265 | running them. |
---|
| 266 | If not specified, the default value is <code>true</code>.</p> |
---|
| 267 | </td></tr><tr><td valign="center" align="left"><code>useNaming</code></td><td valign="center" align="left"> |
---|
| 268 | <p>Set to <code>true</code> (the default) to have Catalina enable a |
---|
| 269 | JNDI <code>InitialContext</code> for this web application that is |
---|
| 270 | compatible with Java2 Enterprise Edition (J2EE) platform |
---|
| 271 | conventions.</p> |
---|
| 272 | </td></tr><tr><td valign="center" align="left"><code>workDir</code></td><td valign="center" align="left"> |
---|
| 273 | <p>Pathname to a scratch directory to be provided by this Context |
---|
| 274 | for temporary read-write use by servlets within the associated web |
---|
| 275 | application. This directory will be made visible to servlets in the |
---|
| 276 | web application by a servlet context attribute (of type |
---|
| 277 | <code>java.io.File</code>) named |
---|
| 278 | <code>javax.servlet.context.tempdir</code> as described in the |
---|
| 279 | Servlet Specification. If not specified, a suitable directory |
---|
| 280 | underneath <code>$CATALINA_BASE/work</code> will be provided.</p> |
---|
| 281 | </td></tr></table> |
---|
| 282 | |
---|
| 283 | </blockquote></td></tr></table> |
---|
| 284 | |
---|
| 285 | |
---|
| 286 | </blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Nested Components"><strong>Nested Components</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 287 | |
---|
| 288 | <p>You can nest at most one instance of the following utility components |
---|
| 289 | by nesting a corresponding element inside your <strong>Context</strong> |
---|
| 290 | element:</p> |
---|
| 291 | <ul> |
---|
| 292 | <li><a href="loader.html"><strong>Loader</strong></a> - |
---|
| 293 | Configure the web application class loader that will be used to load |
---|
| 294 | servlet and bean classes for this web application. Normally, the |
---|
| 295 | default configuration of the class loader will be sufficient.</li> |
---|
| 296 | <li><a href="manager.html"><strong>Manager</strong></a> - |
---|
| 297 | Configure the session manager that will be used to create, destroy, |
---|
| 298 | and persist HTTP sessions for this web application. Normally, the |
---|
| 299 | default configuration of the session manager will be sufficient.</li> |
---|
| 300 | <li><a href="realm.html"><strong>Realm</strong></a> - |
---|
| 301 | Configure a realm that will allow its |
---|
| 302 | database of users, and their associated roles, to be utilized solely |
---|
| 303 | for this particular web application. If not specified, this web |
---|
| 304 | application will utilize the Realm associated with the owning |
---|
| 305 | <a href="host.html">Host</a> or <a href="engine.html">Engine</a>.</li> |
---|
| 306 | <li><a href="resources.html"><strong>Resources</strong></a> - |
---|
| 307 | Configure the resource manager that will be used to access the static |
---|
| 308 | resources associated with this web application. Normally, the |
---|
| 309 | default configuration of the resource manager will be sufficient.</li> |
---|
| 310 | <li><strong>WatchedResource</strong> - The auto deployer will monitor the |
---|
| 311 | specified static resource of the web application for updates, and will |
---|
| 312 | reload the web application if is is updated. The content of this element |
---|
| 313 | must be a string.</li> |
---|
| 314 | </ul> |
---|
| 315 | |
---|
| 316 | </blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Special Features"><strong>Special Features</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 317 | |
---|
| 318 | |
---|
| 319 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Logging"><strong>Logging</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 320 | |
---|
| 321 | <p>A context is associated with the |
---|
| 322 | <code>org.apache.catalina.core.ContainerBase.[enginename].[hostname].[path]</code> |
---|
| 323 | log category. Note that the brackets are actually part of the name, don't omit them.</p> |
---|
| 324 | |
---|
| 325 | </blockquote></td></tr></table> |
---|
| 326 | |
---|
| 327 | |
---|
| 328 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Access Logs"><strong>Access Logs</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 329 | |
---|
| 330 | <p>When you run a web server, one of the output files normally generated |
---|
| 331 | is an <em>access log</em>, which generates one line of information for |
---|
| 332 | each request processed by the server, in a standard format. Catalina |
---|
| 333 | includes an optional <a href="valve.html">Valve</a> implementation that |
---|
| 334 | can create access logs in the same standard format created by web servers, |
---|
| 335 | or in any number of custom formats.</p> |
---|
| 336 | |
---|
| 337 | <p>You can ask Catalina to create an access log for all requests |
---|
| 338 | processed by an <a href="engine.html">Engine</a>, |
---|
| 339 | <a href="host.html">Host</a>, or <a href="context.html">Context</a> |
---|
| 340 | by nesting a <a href="valve.html">Valve</a> element like this:</p> |
---|
| 341 | |
---|
| 342 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 343 | <Context path="/examples" ...> |
---|
| 344 | ... |
---|
| 345 | <Valve className="org.apache.catalina.valves.AccessLogValve" |
---|
| 346 | prefix="localhost_access_log." suffix=".txt" |
---|
| 347 | pattern="common"/> |
---|
| 348 | ... |
---|
| 349 | </Context> |
---|
| 350 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 351 | |
---|
| 352 | <p>See <a href="valve.html#Access Log Valve">Access Log Valve</a> |
---|
| 353 | for more information on the configuration attributes that are |
---|
| 354 | supported.</p> |
---|
| 355 | |
---|
| 356 | </blockquote></td></tr></table> |
---|
| 357 | |
---|
| 358 | |
---|
| 359 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Automatic Context Configuration"><strong>Automatic Context Configuration</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 360 | |
---|
| 361 | <p>If you use the standard <strong>Context</strong> implementation, |
---|
| 362 | the following configuration steps occur automtically when Catalina |
---|
| 363 | is started, or whenever this web application is reloaded. No special |
---|
| 364 | configuration is required to enable this feature.</p> |
---|
| 365 | |
---|
| 366 | <ul> |
---|
| 367 | <li>If you have not declared your own <a href="loader.html">Loader</a> |
---|
| 368 | element, a standard web application class loader will be configured. |
---|
| 369 | </li> |
---|
| 370 | <li>If you have not declared your own <a href="manager.html">Manager</a> |
---|
| 371 | element, a standard session manager will be configured.</li> |
---|
| 372 | <li>If you have not declared your own <a href="resources.html">Resources</a> |
---|
| 373 | element, a standard resources manager will be configured.</li> |
---|
| 374 | <li>The web application properties listed in <code>conf/web.xml</code> |
---|
| 375 | will be processed as defaults for this web application. This is used |
---|
| 376 | to establish default mappings (such as mapping the <code>*.jsp</code> |
---|
| 377 | extension to the corresponding JSP servlet), and other standard |
---|
| 378 | features that apply to all web applications.</li> |
---|
| 379 | <li>The web application properties listed in the |
---|
| 380 | <code>/WEB-INF/web.xml</code> resource for this web application |
---|
| 381 | will be processed (if this resource exists).</li> |
---|
| 382 | <li>If your web application has specified security constraints that might |
---|
| 383 | require user authentication, an appropriate Authenticator that |
---|
| 384 | implements the login method you have selected will be configured.</li> |
---|
| 385 | </ul> |
---|
| 386 | |
---|
| 387 | </blockquote></td></tr></table> |
---|
| 388 | |
---|
| 389 | |
---|
| 390 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Context Parameters"><strong>Context Parameters</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 391 | |
---|
| 392 | <p>You can configure named values that will be made visible to the |
---|
| 393 | web application as servlet context initialization parameters by nesting |
---|
| 394 | <code><Parameter></code> elements inside this element. For |
---|
| 395 | example, you can create an initialization parameter like this:</p> |
---|
| 396 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 397 | <Context ...> |
---|
| 398 | ... |
---|
| 399 | <Parameter name="companyName" value="My Company, Incorporated" |
---|
| 400 | override="false"/> |
---|
| 401 | ... |
---|
| 402 | </Context> |
---|
| 403 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 404 | |
---|
| 405 | <p>This is equivalent to the inclusion of the following element in the |
---|
| 406 | web application deployment descriptor (<code>/WEB-INF/web.xml</code>): |
---|
| 407 | </p> |
---|
| 408 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 409 | <context-param> |
---|
| 410 | <param-name>companyName</param-name> |
---|
| 411 | <param-value>My Company, Incorporated</param-value> |
---|
| 412 | </context-param> |
---|
| 413 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 414 | <p>but does <em>not</em> require modification of the deployment descriptor |
---|
| 415 | to customize this value.</p> |
---|
| 416 | |
---|
| 417 | <p>The valid attributes for a <code><Parameter></code> element |
---|
| 418 | are as follows:</p> |
---|
| 419 | |
---|
| 420 | <table cellpadding="5" border="1"><tr><th bgcolor="#023264" width="15%"><font color="#ffffff">Attribute</font></th><th bgcolor="#023264" width="85%"><font color="#ffffff">Description</font></th></tr><tr><td valign="center" align="left"><code>description</code></td><td valign="center" align="left"> |
---|
| 421 | <p>Optional, human-readable description of this context |
---|
| 422 | initialization parameter.</p> |
---|
| 423 | </td></tr><tr><td valign="center" align="left"><strong><code>name</code></strong></td><td valign="center" align="left"> |
---|
| 424 | <p>The name of the context initialization parameter to be created.</p> |
---|
| 425 | </td></tr><tr><td valign="center" align="left"><code>override</code></td><td valign="center" align="left"> |
---|
| 426 | <p>Set this to <code>false</code> if you do <strong>not</strong> want |
---|
| 427 | a <code><context-param></code> for the same parameter name, |
---|
| 428 | found in the web application deployment descriptor, to override the |
---|
| 429 | value specified here. By default, overrides are allowed.</p> |
---|
| 430 | </td></tr><tr><td valign="center" align="left"><strong><code>value</code></strong></td><td valign="center" align="left"> |
---|
| 431 | <p>The parameter value that will be presented to the application |
---|
| 432 | when requested by calling |
---|
| 433 | <code>ServletContext.getInitParameter()</code>.</p> |
---|
| 434 | </td></tr></table> |
---|
| 435 | |
---|
| 436 | </blockquote></td></tr></table> |
---|
| 437 | |
---|
| 438 | |
---|
| 439 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Environment Entries"><strong>Environment Entries</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 440 | |
---|
| 441 | <p>You can configure named values that will be made visible to the |
---|
| 442 | web application as environment entry resources, by nesting |
---|
| 443 | <code><Environment></code> entries inside this element. For |
---|
| 444 | example, you can create an environment entry like this:</p> |
---|
| 445 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 446 | <Context ...> |
---|
| 447 | ... |
---|
| 448 | <Environment name="maxExemptions" value="10" |
---|
| 449 | type="java.lang.Integer" override="false"/> |
---|
| 450 | ... |
---|
| 451 | </Context> |
---|
| 452 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 453 | |
---|
| 454 | <p>This is equivalent to the inclusion of the following element in the |
---|
| 455 | web application deployment descriptor (<code>/WEB-INF/web.xml</code>): |
---|
| 456 | </p> |
---|
| 457 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 458 | <env-entry> |
---|
| 459 | <env-entry-name>maxExemptions</param-name> |
---|
| 460 | <env-entry-value>10</env-entry-value> |
---|
| 461 | <env-entry-type>java.lang.Integer</env-entry-type> |
---|
| 462 | </env-entry> |
---|
| 463 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 464 | <p>but does <em>not</em> require modification of the deployment descriptor |
---|
| 465 | to customize this value.</p> |
---|
| 466 | |
---|
| 467 | <p>The valid attributes for an <code><Environment></code> element |
---|
| 468 | are as follows:</p> |
---|
| 469 | |
---|
| 470 | <table cellpadding="5" border="1"><tr><th bgcolor="#023264" width="15%"><font color="#ffffff">Attribute</font></th><th bgcolor="#023264" width="85%"><font color="#ffffff">Description</font></th></tr><tr><td valign="center" align="left"><code>description</code></td><td valign="center" align="left"> |
---|
| 471 | <p>Optional, human-readable description of this environment entry.</p> |
---|
| 472 | </td></tr><tr><td valign="center" align="left"><strong><code>name</code></strong></td><td valign="center" align="left"> |
---|
| 473 | <p>The name of the environment entry to be created, relative to the |
---|
| 474 | <code>java:comp/env</code> context.</p> |
---|
| 475 | </td></tr><tr><td valign="center" align="left"><code>override</code></td><td valign="center" align="left"> |
---|
| 476 | <p>Set this to <code>false</code> if you do <strong>not</strong> want |
---|
| 477 | an <code><env-entry></code> for the same environment entry name, |
---|
| 478 | found in the web application deployment descriptor, to override the |
---|
| 479 | value specified here. By default, overrides are allowed.</p> |
---|
| 480 | </td></tr><tr><td valign="center" align="left"><strong><code>type</code></strong></td><td valign="center" align="left"> |
---|
| 481 | <p>The fully qualified Java class name expected by the web application |
---|
| 482 | for this environment entry. Must be one of the legal values for |
---|
| 483 | <code><env-entry-type></code> in the web application deployment |
---|
| 484 | descriptor: <code>java.lang.Boolean</code>, |
---|
| 485 | <code>java.lang.Byte</code>, <code>java.lang.Character</code>, |
---|
| 486 | <code>java.lang.Double</code>, <code>java.lang.Float</code>, |
---|
| 487 | <code>java.lang.Integer</code>, <code>java.lang.Long</code>, |
---|
| 488 | <code>java.lang.Short</code>, or <code>java.lang.String</code>.</p> |
---|
| 489 | </td></tr><tr><td valign="center" align="left"><strong><code>value</code></strong></td><td valign="center" align="left"> |
---|
| 490 | <p>The parameter value that will be presented to the application |
---|
| 491 | when requested from the JNDI context. This value must be convertable |
---|
| 492 | to the Java type defined by the <code>type</code> attribute.</p> |
---|
| 493 | </td></tr></table> |
---|
| 494 | |
---|
| 495 | </blockquote></td></tr></table> |
---|
| 496 | |
---|
| 497 | |
---|
| 498 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Lifecycle Listeners"><strong>Lifecycle Listeners</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 499 | |
---|
| 500 | <p>If you have implemented a Java object that needs to know when this |
---|
| 501 | <strong>Context</strong> is started or stopped, you can declare it by |
---|
| 502 | nesting a <strong>Listener</strong> element inside this element. The |
---|
| 503 | class name you specify must implement the |
---|
| 504 | <code>org.apache.catalina.LifecycleListener</code> interface, and |
---|
| 505 | the class must be packaged in a jar and placed in the |
---|
| 506 | <code>$CATALINA_HOME/lib</code> directory. |
---|
| 507 | It will be notified about the occurrence of the corresponding |
---|
| 508 | lifecycle events. Configuration of such a listener looks like this:</p> |
---|
| 509 | |
---|
| 510 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 511 | <Context path="/examples" ...> |
---|
| 512 | ... |
---|
| 513 | <Listener className="com.mycompany.mypackage.MyListener" ... > |
---|
| 514 | ... |
---|
| 515 | </Context> |
---|
| 516 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 517 | |
---|
| 518 | <p>Note that a Listener can have any number of additional properties |
---|
| 519 | that may be configured from this element. Attribute names are matched |
---|
| 520 | to corresponding JavaBean property names using the standard property |
---|
| 521 | method naming patterns.</p> |
---|
| 522 | |
---|
| 523 | </blockquote></td></tr></table> |
---|
| 524 | |
---|
| 525 | |
---|
| 526 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Request Filters"><strong>Request Filters</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 527 | |
---|
| 528 | <p>You can ask Catalina to check the IP address, or host name, on every |
---|
| 529 | incoming request directed to the surrounding |
---|
| 530 | <a href="engine.html">Engine</a>, <a href="host.html">Host</a>, or |
---|
| 531 | <a href="context.html">Context</a> element. The remote address or name |
---|
| 532 | will be checked against a configured list of "accept" and/or "deny" |
---|
| 533 | filters, which are defined using the Regular Expression syntax supported |
---|
| 534 | by the <a href="http://jakarta.apache.org/regexp/">Jakarta Regexp</a> |
---|
| 535 | regular expression library. Requests that come from locations that are |
---|
| 536 | not accepted will be rejected with an HTTP "Forbidden" error. |
---|
| 537 | Example filter declarations:</p> |
---|
| 538 | |
---|
| 539 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 540 | <Context path="/examples" ...> |
---|
| 541 | ... |
---|
| 542 | <Valve className="org.apache.catalina.valves.RemoteHostValve" |
---|
| 543 | allow="*.mycompany.com,www.yourcompany.com"/> |
---|
| 544 | <Valve className="org.apache.catalina.valves.RemoteAddrValve" |
---|
| 545 | deny="192.168.1.*"/> |
---|
| 546 | ... |
---|
| 547 | </Context> |
---|
| 548 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 549 | |
---|
| 550 | <p>See <a href="valve.html#Remote Address Filter">Remote Address Filter</a> |
---|
| 551 | and <a href="valve.html#Remote Host Filter">Remote Host Filter</a> for |
---|
| 552 | more information about the configuration options that are supported.</p> |
---|
| 553 | |
---|
| 554 | </blockquote></td></tr></table> |
---|
| 555 | |
---|
| 556 | |
---|
| 557 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Resource Definitions"><strong>Resource Definitions</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 558 | |
---|
| 559 | <p>You can declare the characteristics of the resource |
---|
| 560 | to be returned for JNDI lookups of <code><resource-ref></code> and |
---|
| 561 | <code><resource-env-ref></code> elements in the web application |
---|
| 562 | deployment descriptor. You <strong>MUST</strong> also define |
---|
| 563 | the needed resource parameters as attributes of the <code>Resource</code> |
---|
| 564 | element, to configure the object factory to be used (if not known to Tomcat |
---|
| 565 | already), and the properties used to configure that object factory.</p> |
---|
| 566 | |
---|
| 567 | <p>For example, you can create a resource definition like this:</p> |
---|
| 568 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 569 | <Context ...> |
---|
| 570 | ... |
---|
| 571 | <Resource name="jdbc/EmployeeDB" auth="Container" |
---|
| 572 | type="javax.sql.DataSource" |
---|
| 573 | description="Employees Database for HR Applications"/> |
---|
| 574 | ... |
---|
| 575 | </Context> |
---|
| 576 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 577 | |
---|
| 578 | <p>This is equivalent to the inclusion of the following element in the |
---|
| 579 | web application deployment descriptor (<code>/WEB-INF/web.xml</code>):</p> |
---|
| 580 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 581 | <resource-ref> |
---|
| 582 | <description>Employees Database for HR Applications</description> |
---|
| 583 | <res-ref-name>jdbc/EmployeeDB</res-ref-name> |
---|
| 584 | <res-ref-type>javax.sql.DataSource</res-ref-type> |
---|
| 585 | <res-auth>Container</res-auth> |
---|
| 586 | </resource-ref> |
---|
| 587 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 588 | |
---|
| 589 | <p>but does <em>not</em> require modification of the deployment |
---|
| 590 | descriptor to customize this value.</p> |
---|
| 591 | |
---|
| 592 | <p>The valid attributes for a <code><Resource></code> element |
---|
| 593 | are as follows:</p> |
---|
| 594 | |
---|
| 595 | <table cellpadding="5" border="1"><tr><th bgcolor="#023264" width="15%"><font color="#ffffff">Attribute</font></th><th bgcolor="#023264" width="85%"><font color="#ffffff">Description</font></th></tr><tr><td valign="center" align="left"><code>auth</code></td><td valign="center" align="left"> |
---|
| 596 | <p>Specify whether the web Application code signs on to the |
---|
| 597 | corresponding resource manager programatically, or whether the |
---|
| 598 | Container will sign on to the resource manager on behalf of the |
---|
| 599 | application. The value of this attribute must be |
---|
| 600 | <code>Application</code> or <code>Container</code>. This |
---|
| 601 | attribute is <strong>required</strong> if the web application |
---|
| 602 | will use a <code><resource-ref></code> element in the web |
---|
| 603 | application deployment descriptor, but is optional if the |
---|
| 604 | application uses a <code><resource-env-ref></code> instead.</p> |
---|
| 605 | </td></tr><tr><td valign="center" align="left"><code>description</code></td><td valign="center" align="left"> |
---|
| 606 | <p>Optional, human-readable description of this resource.</p> |
---|
| 607 | </td></tr><tr><td valign="center" align="left"><strong><code>name</code></strong></td><td valign="center" align="left"> |
---|
| 608 | <p>The name of the resource to be created, relative to the |
---|
| 609 | <code>java:comp/env</code> context.</p> |
---|
| 610 | </td></tr><tr><td valign="center" align="left"><code>scope</code></td><td valign="center" align="left"> |
---|
| 611 | <p>Specify whether connections obtained through this resource |
---|
| 612 | manager can be shared. The value of this attribute must be |
---|
| 613 | <code>Shareable</code> or <code>Unshareable</code>. By default, |
---|
| 614 | connections are assumed to be shareable.</p> |
---|
| 615 | </td></tr><tr><td valign="center" align="left"><strong><code>type</code></strong></td><td valign="center" align="left"> |
---|
| 616 | <p>The fully qualified Java class name expected by the web |
---|
| 617 | application when it performs a lookup for this resource.</p> |
---|
| 618 | </td></tr></table> |
---|
| 619 | |
---|
| 620 | |
---|
| 621 | </blockquote></td></tr></table> |
---|
| 622 | |
---|
| 623 | |
---|
| 624 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Resource Links"><strong>Resource Links</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 625 | |
---|
| 626 | <p>This element is used to create a link to a global JNDI resource. Doing |
---|
| 627 | a JNDI lookup on the link name will then return the linked global |
---|
| 628 | resource.</p> |
---|
| 629 | |
---|
| 630 | <p>For example, you can create a resource link like this:</p> |
---|
| 631 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 632 | <Context ...> |
---|
| 633 | ... |
---|
| 634 | <ResourceLink name="linkToGlobalResource" |
---|
| 635 | global="simpleValue" |
---|
| 636 | type="java.lang.Integer" |
---|
| 637 | ... |
---|
| 638 | </Context> |
---|
| 639 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 640 | |
---|
| 641 | <p>The valid attributes for a <code><ResourceLink></code> element |
---|
| 642 | are as follows:</p> |
---|
| 643 | |
---|
| 644 | <table cellpadding="5" border="1"><tr><th bgcolor="#023264" width="15%"><font color="#ffffff">Attribute</font></th><th bgcolor="#023264" width="85%"><font color="#ffffff">Description</font></th></tr><tr><td valign="center" align="left"><strong><code>global</code></strong></td><td valign="center" align="left"> |
---|
| 645 | <p>The name of the linked global resource in the |
---|
| 646 | global JNDI context.</p> |
---|
| 647 | </td></tr><tr><td valign="center" align="left"><strong><code>name</code></strong></td><td valign="center" align="left"> |
---|
| 648 | <p>The name of the resource link to be created, relative to the |
---|
| 649 | <code>java:comp/env</code> context.</p> |
---|
| 650 | </td></tr><tr><td valign="center" align="left"><strong><code>type</code></strong></td><td valign="center" align="left"> |
---|
| 651 | <p>The fully qualified Java class name expected by the web |
---|
| 652 | application when it performs a lookup for this resource link.</p> |
---|
| 653 | </td></tr></table> |
---|
| 654 | |
---|
| 655 | </blockquote></td></tr></table> |
---|
| 656 | |
---|
| 657 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Transaction"><strong>Transaction</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 658 | |
---|
| 659 | <p>You can declare the characteristics of the UserTransaction |
---|
| 660 | to be returned for JNDI lookup for <code>java:comp/UserTransaction</code>. |
---|
| 661 | You <strong>MUST</strong> define an object factory class to instantiate |
---|
| 662 | this object as well as the needed resource parameters as attributes of the |
---|
| 663 | <code>Transaction</code> |
---|
| 664 | element, and the properties used to configure that object factory.</p> |
---|
| 665 | |
---|
| 666 | <p>The valid attributes for the <code><Transaction></code> element |
---|
| 667 | are as follows:</p> |
---|
| 668 | |
---|
| 669 | <table cellpadding="5" border="1"><tr><th bgcolor="#023264" width="15%"><font color="#ffffff">Attribute</font></th><th bgcolor="#023264" width="85%"><font color="#ffffff">Description</font></th></tr><tr><td valign="center" align="left"><strong><code>factory</code></strong></td><td valign="center" align="left"> |
---|
| 670 | <p>The class name for the JNDI object factory.</p> |
---|
| 671 | </td></tr></table> |
---|
| 672 | |
---|
| 673 | </blockquote></td></tr></table> |
---|
| 674 | |
---|
| 675 | </blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr size="1" noshade></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font size="-1" color="#525D76"><em> |
---|
| 676 | Copyright © 1999-2008, Apache Software Foundation |
---|
| 677 | </em></font></div></td></tr></table></body></html> |
---|