The Context Component


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

Introduction

A Context component represents an individual web application that is running within a particular Host. Such a web application is based on a directory whose organization is described in the Servlet API Specification, version 2.2 -- including the web application deployment descriptor file, found in "WEB-INF/web.xml".

Contextコンポーネントは、特定の ホストの範囲内で実行している個々のWebアプリケーションを表します。 そのようなWebアプリケーションは組織化がServlet API仕様書バージョン2.2 で記述されるディレクトリに基づいたWebアプリケーション配備記述ファイルを 含まれ、"WEB-INF/web.xml"で見つけることができます。

The web application used to process a particular request is selected by Catalina based on matching the longest possible prefix of the request URI against the context path of each defined Context. Once selected, that Context will select an appropriate servlet to process the incoming request, according to the servlet mappings defined in the web application deployment descriptor, based on the request mapping rules that are also found in the servlet specification.

特定の要求を処理するために使われるWebアプリケーションは、 contextに対して要求URIの最も長く可能な接頭辞に各定義されたコンテキストの pathに合うものを見つけることに基づくCatalinaによって選ばれます。 一旦選ばれるならば、そのコンテキストは適切なservletを、Webアプリケーション 配備記述で定義されるservlet mappingsによれば、入って来る要求を処理するのに 選ぶことになります。そして、また、servlet仕様書において見つけられる規則を 写像している要求に基づきます。

You may define as many Context components as you wish, nested within a Host component in the conf/server.xml file. Each such Context must have a unique context path, defined by the path attribute. In addition, you must define a context with a path equal to a zero-length string, which becomes the default web application to process requests when a different context cannot be matched. There are also special features of the Host configuration that enable automatic creation of Context components without having to explicitly mention them.

あなたとしてのコンポーネントが願う多くのContextconf/server.xmlファイルにおいて、Host コンポーネントの範囲内でネストしていたので、あなたは定義するかもしれません。 そのような各コンテキストは素晴らしいコンテキスト・パスを持たなければなりません。 そして、path属性によって定義されます。 その他に、あなた、mustは、異なるコンテキストがマッチされる ことができないプロセス要求へのデフォルトのWebアプリケーションになるゼロ-長ストリングと 等しいパスで、コンテキストを定義します。 Contextコンポーネントの自動作成を可能にする Host構成のまた、特別な機能が、 明確にそれらに言及しなければならないことなくあります。

Request processing Valves that are nested here will be executed for every request received for processing by this web application.

ある処理Valvesがここでネストしていたという要求は、 このWebアプリケーションによって処理のために受け取られるあらゆる要求のために 実行されることになります。


Common Attributes

共通属性

All implementations of the Context component support the following attributes:

Context コンポーネントのすべての実装 は、以下の属性をサポートします。

Attribute Description
className Java class name of the implementation to use. This class must implement the org.apache.catalina.Context interface. If no class name is specified, the standard implementation will be used (org.apache.catalina.core.StandardContext).
className 使用する実装のJavaクラス名。このクラスは、 org.apache.catalina.Context インタフェースを 実装する必要があります。もしクラス名が指定されない場合には、 標準実装が使用されます (org.apache.catalina.core.StandardContext).
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.
cookies クライアントによってサポートされていて、クッキーを使用してセッション 識別を行ないたい場合には、trueにセットします。 セッションIDクッキーを使用せずにURLリライトだけをしようする場合には falseをセットします。 指定されない場合には、デフォルト値はtureです。
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.
crossContext このアプリケーション内部から、ホストの他のWebアプリケーションを実行するために、ServletContext.getContext()を呼び出し、その戻り値としてServletContextが帰ってくるようにしたい場合には、tureにセットします。 セキュリティに配慮したい環境ではgetContext()呼び出しがnullを返すことになるように、falseにセットしてください。 デフォルトの値は、falseです。
docBase The "document base" directory for this web application. This is the pathname of a directory that contains the static resources (such as HTML pages and images) for this application, plus a WEB-INF subdirectory containing the "web.xml" deployment descriptor and other configuration information. You may specify an absolute pathname to this directory, or a pathname that is relative to the "application base" for the Host within which this application is defined.
docBase このWebアプリケーションのための"document base"ディレクトリ。 これは、「web.xml」配備記述と他の構成情報を含んでいるWeb-INFサブディレクトリをプラスして、このアプリケーションのために静的リソース(例えばHTMLページとイメージ)を含むディレクトリのパス名です。 あなたはこのディレクトリに絶対のパス名を指定するかもしれません、あるいは、このアプリケーションがどちらであるかについて、Hostのために「アプリケーション・ベース」と関連しているパス名が定義しました。
path The context path for this web application, which is matched against the beginning of a request URI to select the appropriate application. All of the context paths within a particular Host must be unique. In addition, you must specify a Context with a path equal to a zero-length string, which will become the default context for this Host.
path 適切なアプリケーションを選ぶために要求URIを開始することと比べられるこのWebアプリケーションのためのコンテキスト・パス。 特定のHostの範囲内のコンテキスト・パスの全ては、ユニークでなければなりません。 その他に、同等、長さ0の文字列、これのためのデフォルトのコンテキストになることになるpathであなたはContextを指定しなければなりません主催します。
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.
reloadable あなたがCatalinaをWEB-INF/classesでクラスをチェックしてもらいたいならば、この属性をtrueにセットしてください、そして、変更点が見つけられるならば、WEB-INF/libは修正のために、そして、自動的にこのアプリケーションを再ロードします。 この機能は、開発の間、非常に役に立ちます。 しかし、それは重要な実行時オーバーヘッドを必要とするので、それが製品配備の場合には、推奨されません。
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.
wrapperClass このコンテキストによって管理されるservletsのために使われることになるorg.apache.catalina.Wrapper実装クラスのJavaクラス名。 指定されないならば、標準の値(org.apache.catalina.core.StandardWrapper)が使われることになります。
useNaming Set this attribute to true if you wish to have Catalina enable JNDI. Default is true.
useNaming あなたがCatalinaをJNDIを可能にしてもらいたいならば、この属性をtrueにセットしてください。 デフォルトは、trueです。
override Set this attribute to true if you wish to over ride the DefaultContext configuration. Default is false.
override DefaultContext構成をオーバーライドしたい場合には、この属性をtrueにセットしてください。 デフォルトは、falseです。

Standard Implementation Attributes

The standard implementation of the Context component also supports the following attributes:

Contextコンポーネントの標準の実装も、属性に追従することをサポートします:

Attribute Description
debug The level of debugging detail logged by this Context to the associated Logger, with higher numbers generating more detailed output. If not specified, the debugging detail level will be set to zero (0).
debug より詳細な出力を生成しているより高い番号で、詳細をデバッグするレベルは、関連されたLoggerにこのContextによって記録しました。 指定されないならば、詳細レベルをデバッグすることはゼロ(0)にセットされることになります。
workDir Pathname to a scratch directory to be provided by this Context for temporary read-write use by servlets within this application. The corresponding directory will be made visible as a servlet context attribute (of type java.io.File) with the standard name assigned by the Servlet API Specification, version 2.2 (javax.servlet.context.tempdir). If not specified, a suitable directory underneath Catalina's home directory will be assigned automatically.
workDir このアプリケーションの範囲内でservletsによって一時的なread-write使用のためにこのコンテキストによって提供されるかき傷ディレクトリへのパス名。 対応するディレクトリは、Servlet API仕様書(バージョン2.2(javax.servlet.context.tempdir))によって割り当てられる標準の名前で、servletコンテキスト属性(タイプjava.io.Fileの)として見えるようにされることになります。 指定されないならば、Catalinaのホーム・ディレクトリの下の適当なディレクトリは自動的に割り当てられることになります。

Utility Components

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

あなたは、ネストしていることによってユーティリティ・コンポーネントに追従する一つ以上を付けることができますあなたのContext要素の中に対応する宣言。


Special Features

特別な機能

Access Logs

アクセスログ

When you run a web server, one of the output files normally generated is an access log, which generates one line of information, in a standard format, for each HTTP request that was received, and responded to, by the web server. Catalina includes an optional Valve implementation that can create access logs in the same standard format created by web servers, or in any custom format desired.

あなたがWebサーバーを実行するとき、通常発生する出力ファイルのうちの1つはaccess logです。そして、受け取られて、Webサーバーで応答された各HTTP要求のために、標準のフォーマットで、それは情報の1本の行を生成します。 Catalinaは、アクセスをつくることができるValve実装がWebサーバーで構築される同じ標準のフォーマットでまたは要求されるどんなカスタム・フォーマットででも記録するオプションのを含みます。

You can ask Catalina to create an access log for all requests to this web application, by nesting an element like this inside your Context element:

あなたは、あなたのContext要素の中に、ネストして全てのためのログがこのWebアプリケーションに要請するアクセスをつくるCatalinaにこれのような要素を尋ねることができます:


    <Context path="/myapp" ...>
      ...
      <Valve className="org.apache.catalina.valves.AccessLogValve"
             prefix="myapp_access_log." suffix=".txt"
             pattern="common"/>
      ...
    </Context>

See Access Log Valve for more information on the configuration options that are supported.

サポートされる構成オプションについて、 詳細はアクセスログ値を みてください。

Automatic Context Configuration

自動コンテキスト設定

If you use the standard Context implementation, the following configuration occurs automatically when Catalina is started, or whenever this web application is restarted. No special configuration is necessary to enable this activity.

あなたが標準のContext実装を使うならば、Catalinaが始まるとき、あるいは、このWebアプリケーションが再開されるときはいつでも、構成に追従することは自動的に起こります。 特別な構成は、この活動を可能にするために必要ではありません。

NOTE: The automatic context configuration steps described above are applied both to contexts specifically listed in the conf/server.xml file, as well as contexts automatically created by the owning Host component.

NOTE: 上で記述される自動コンテキスト構成ステップは、両方ともconf/server.xmlファイル(Hostコンポーネントを所有することによって自動的に生成されるコンテキストと同様に)に、特にリストされるコンテキストに適用されます。

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.

あなたがこのContextがいつかについて知っている必要が始めたJavaオブジェクトを実装するか、立ち止まったならば、あなたがネストしていることによってそれを宣言することができて、< Listener> < Context> 要素の中にcode>要素。 あなたがこのリスナーのclassName属性において、指定するクラスはorg.apache.catalina.LifecycleListenerインタフェースを実装しなければなりません、そして、それは対応するライフサイクル・イベントの出来事について通知されることになります。

Configuration for such a listener might look like this:

そのようなリスナーのための構成は、これのように見えるかもしれません:


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

Request Filters

You can ask Catalina to check the IP address, or host name, of an incoming request for this web application against a list of "accept" and "deny" filters, which are defined using the Regular Expression syntax supported by the jakarta-regexp regular expression library system. Requests that come from remote locations that are not accepted will be rejected with an HTTP "Forbidden" error. Example filter declarations:

あなたは、チェックへのCatalinaにIPアドレスを尋ねることができるか、名前を主催することができます、リストに対するこのWebアプリケーションの入って来る要求ののjakarta-regexp正規表現ライブラリ・システムによってサポートされる正規表現構文を使って定義されるフィルタを「受け入れ」て、そして、「否定します」。 受け入れられないリモート位置からやって来る要求は、HTTP「禁じられた」エラーで拒否されることになります。 例フィルタ宣言:


    <Context path="/myapp" ...>
      ...
      <Valve className="org.apache.catalina.valves.RemoteHostValve"
             allow="*.mycompany.com,www.yourcompany.com"/>
      <Valve className="org.apache.catalina.valves.RemoteAddrValve"
             deny="192.168.1.*"
      ...
    </Context>

See Remote Address Filter or Remote Host Filter for more information on the syntax of these filters, and the logic that is applied when they are executed.

リモート・アドレス・フィルターについて言及するのを見てください、さもなければ、Remote ホストフィルターはこれらのフィルタの構文に関するより多くの情報と彼らが実行されるとき、適用されるロジックします。