Adding a Context

See Also

When you deploy a web module to a Tomcat server or execute the web module, the IDE adds a Context element to the server's configuration file (server.xml), if one does not already exist. This Context element declares that, when the server is started, the server must load the web module with the properties specified in the Context element.

The IDE uses the Context Root property value from the WEB-INF property sheet to set the path attribute in the Context element. This path becomes the context root that the Servlet engine creates for the web module. The context root is the path to the web module. For example, if the Context Root property value is /directives, then a resource named index.html under the web module's root can be accessed using the URL http://host:port/directives/index.html.

When the server receives the HTTP request, the server selects the web module for processing the request by matching the longest possible prefix of the Request URI against the context path of each defined Context. You can define an unlimited number of Context elements within a particular Host, and you can define more than one Context element for a web module. Each Context must have a unique context path.

Typically, because the IDE adds context elements automatically, you do not need to create context elements explicitly. However, if you should choose to do so, perform the following steps.

To deploy a web module by adding a Context element:

  1. On the Runtime tab of the Explorer, expand the Installed Servers node.
  2. Expand the Tomcat node, then expand the node for the relevant installation.
  3. Right-click on the node representing the Host to which you want to add a Context, then choose Add Context from the contextual menu.
  4. In the Add Context dialog box, select the appropriate web module, then enter a unique path in the Context Path field.
  5. Click OK. A new Context node appears under its Host on the Runtime tab in the Explorer. Using the contextual menu for this node, you can set properties for the Context.
  6. Restart the server.
See Also
Tomcat Context Node
Setting Context Properties
Deleting a Context

Legal Notices