Servlet Development Guide : PART II Administration : Chapter 4 Configuring Objects in the Servlet Container
Chapter 4 Configuring Objects in the Servlet Container
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. “Servlet and Filter Initialization Parameters” discusses initialization parameters. “URL Patterns” explains URL pattern matching. The remainder of the chapter, beginning with “Deploy the Compiled Object Files” , describes tasks associated with adding a context, as summarized in the next section.
Procedure for Adding a Context
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 (“Deploy the Compiled Object Files” ). 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 (“Create a Context Directory” ). All contexts require this step.
Add context parameters to the web.xml file (“Set Context Parameters” ).
Define servlets and map them to URL patterns (“Define and Map Servlets” ).
Define filters and map them to URL patterns (“Define and Map Filters” ).
Define listeners (“Define Listeners” ).
Define error page handlers (“Configure Error Pages” ).
Define session characteristics (“Configure Sessions” ).
Configure an external Web server (“Forward Requests From a Web Server” ).
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.
Procedure for Adding a Servlet
To add a servlet to an existing context, follow the steps below:
Deploy the compiled servlet file to a directory known to the Agent (“Deploy the Compiled Object Files” )
Define the servlet and map the servlet to a URL pattern (“Define and Map Servlets” )
Stop and restart the Agent to load the servlet.
Procedure for Adding a Filter
To add a filter to an existing context, follow the steps below:
Deploy the compiled filter file to a directory know to the Agent (“Deploy the Compiled Object Files” )
Define the filter and map the filter to one or more URL patterns (“Define and Map Filters” )
Stop and restart the Agent to load the servlet and its associated filter.
Procedure for Adding a Listener
To add a listener to an existing context, follow the steps below:
Deploy the compiled listener file to a directory know to the Agent (“Deploy the Compiled Object Files” )
Define the listener (“Define and Map Filters” )
Stop and restart the Agent to load the servlet and its associated listener.