Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress Servlet Development Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

4.1 Introduction

Each servlet, filter, and listener in the servlet container exists within a context. This chapter describes the tasks involved in creating a new context and configuring a context.

Each servlet and each filter must have a URL pattern mapping, and may have initialization parameters. Section 4.2 discusses initialization parameters. Section 4.3 explains URL pattern matching.

4.1.1 Procedure for Adding a Context

The remainder of this chapter covers the steps listed below. All contexts must have access to the library files that contain the compiled servlets. The contexts are specified in <<installdir>>\apps\servlets, but the libraries can be anywhere in the path.

The first two steps are required for all contexts. Whether the other steps are necessary or not depends on the context. For example, if no servlets or filters in the context require context parameters, there is no need to add parameters to the context.

To add a context:

To load the context, stop and restart the HydraExpress service execution engine (which implements the servlet container). The HydraExpress User's Guide can tell you how. The execution engine reports unrecoverable errors to the console. Errors in a context web.xml file appear in the Agent log if the Agent has logging enabled.

4.1.2 Procedure for Adding a Servlet

To add a servlet to an existing context, follow the steps below:

Stop and restart the Agent to load the servlet.

4.1.3 Procedure for Adding a Filter

To add a filter to an existing context, follow the steps below:

Stop and restart the Agent to load the servlet.

4.1.4 Procedure for Adding a Listener

To add a listener to an existing context, follow the steps below:

Stop and restart the Agent to load the servlet.

4.1.5 Sample Configuration File

The example below is a simple context web.xml file. The context that this file defines contains a servlet, a filter that processes requests for the servlet, and a listener. Sessions in the context time out after 10 minutes. The file declares the 404.html document in the root directory of the context as the page the servlet container will return in response to a 404 error within the context.

A production application generally has a more elaborate configuration file. A file can contain any number of servlet, filter, and listener declarations. A file may contain one session-config element, and one error-page element for each HTTP error code.

4.1.6 Character Set

The web.xml file may be encoded in either UTF-8 or UTF-16. The container transcodes the file to UTF-8 before passing strings to a servlet or filter. Initialization parameter names, initialization parameter values, servlet names, and filter names are expressed as UTF-8 within a running container.

Previous fileTop of DocumentContentsIndex pageNext file

©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.