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.3 discusses initialization parameters. Section 4.4 explains URL pattern matching. The remainder of the chapter, beginning with Section 4.5, describes tasks associated with adding a context, as summarized in the next section.
The list below describes the tasks that could be involved in adding a servlet context. The first two tasks, deploying the libraries needed by the context and creating a context directory, are required for all contexts. The other tasks may or may not be required depending on the needs of the context. For example, if no servlets or filters in the context depend on context parameters, there is no need to add parameters to the context.
To add a context:
Deploy the files that contain the compiled servlets, filters, and listeners that the context will contain (Section 4.5). All contexts require this step.
Create a context directory that contains a WEB-INF directory and create a web.xml file within the WEB-INF directory (Section 4.6). All contexts require this step.
Add context parameters to the web.xml file (Section 4.7).
Define servlets and map them to URL patterns (Section 4.8).
Define filters and map them to URL patterns (Section 4.9).
Define listeners (Section 4.10).
Define error page handlers (Section 4.11).
Define session characteristics (Section 4.12).
Configure an external Web server (Section 4.13).
To activate a new context, it must be loaded into the HydraExpress Agent. This is done simply by stopping and restarting the Agent, as described in Chapter 4, "Agent Administration," of the HydraExpress User Guide. The Agent reports unrecoverable errors to the console. Errors defined in the context web.xml file are written to the Agent log, assuming the Agent has logging enabled.
To add a servlet to an existing context, follow the steps below:
Deploy the compiled servlet file to a directory know to the Agent (Section 4.5)
Define the servlet and map the servlet to a URL pattern (Section 4.8)
Stop and restart the Agent to load the servlet.
To add a filter to an existing context, follow the steps below:
Deploy the compiled filter file to a directory know to the Agent (Section 4.5)
Define the filter and map the filter to one or more URL patterns (Section 4.9)
Stop and restart the Agent to load the servlet and its associated filter.
To add a listener to an existing context, follow the steps below:
Deploy the compiled listener file to a directory know to the Agent (Section 4.5)
Define the listener (Section 4.9)
Stop and restart the Agent to load the servlet and its associated listener.
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo are registered trademarks of Rogue Wave Software, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.