# The DefaultContext Component

[Introduction] [Common Attributes] [Utility Components] [Special Features]

## Introduction

A DefaultContext component represents a subset of the Context configuration elements. A `DefaultContext` can be nested within an Engine or Host.

The elements you configure for a `DefaultContext` within both the `Engine` and `Host` elements are added to the configuration of any automatically created web application context or configured context.

If you wish to configure a `Context` which does not use the `DefaultContext` configuration set the `Context` attribute `override="true"`.

## Common Attributes

All implementations of the Context component support the following attributes:

Attribute | Description
--- | ---
`cookies` | Set to `true` if you want cookies to be used for session identifier communication (if supported by the client). Set to `false` if you want to skip even trying session id cookies, and rely only on URL rewriting. If not specified, the default value is `true`.
`crossContext` | Set to `true` of you want calls from within this application to `ServletContext.getContext()` to successfully return the `ServletContext` for other web applications running in this host. Set to `false` in security conscious environments, so that `getContext()` calls will return `null`. The default value is `false`.
`reloadable` | Set this attribute to `true` if you wish to have Catalina check the classes in `WEB-INF/classes` and `WEB-INF/lib` for modification, and automatically reload this application if a change is detected. This feature is very useful during development; however, it requires significant runtime overhead so it is not recommended for production deployment scenarios.
`wrapperClass` | Java class name of the `org.apache.catalina.Wrapper` implementation class that will be used for servlets managed by this Context. If not specified, the standard value (`org.apache.catalina.core.StandardWrapper`) will be used.
`useNaming` | Set this attribute to `true` if you wish to have Catalina enable JNDI. Default is `true`.

## Utility Components

You can attach one or more of the following utility components by nesting a corresponding declaration inside your Host element.

- Loader - Configure a class loader associated with this Context.
- Manager - Configure a session manager for the sessions associated with this Context.
- Resources - Configure access to the static resources associated with this Context

## Special Features

### Lifecycle Listeners

If you have implemented a Java object that needs to know when this Context is started or stopped, you can declare it by nesting a `<Listener>` element inside the `<Context>` element. The class you specify in the `className` attribute of this Listener must implement the `org.apache.catalina.LifecycleListener` interface, and it will be notified about the occurrence of the corresponding lifecycle events.

Configuration for such a listener might look like this:

        <Context path="/myapp" ...>
          ...
          <Listener className="com.mycompany.MyAppListener"/>
          ...
        </Context>