|
Home TOC Index |
|
Search
Feedback |
Configuring Web Clients
The following sections describe the Web client configuration parameters that you will usually want to specify. Configuration parameters are specified at three levels: application, WAR, and component. A number of security parameters can be applied at the WAR and component levels. For information on these security parameters, see Web-Tier Security.
Application-Level Configuration
Context Root
A context root is a name that gets mapped to the document root of a Web client. If your client's context root is
catalog, then the request URLhttp://<host>:8000/catalog/index.htmlwill retrieve the file
index.htmlfrom the document root.To specify the context root for
Hello1Appindeploytool,WAR-Level Configuration
The following sections give generic procedures for specifying WAR-level configuration information. For some specific examples, see The Example Servlets.
Context Parameters
The Web components in a WAR share an object that represents their Web context (see Accessing the Web Context). To specify initialization parameters that are passed to the context,
References to Environment Entries, Enterprise Beans, Resource Environment Entries, or Resources
If your Web components reference environment entries, enterprise beans, resource environment entries, or resources such as databases, you must declare the references as follows:
- Select the WAR.
- Select the Environment, Enterprise Bean Refs, Resource Env. Refs or Resource Refs tab.
- Click Add in the pane to add a new reference.
Event Listeners
To add an event listener class (described in Handling Servlet Life-Cycle Events),
- Select the WAR.
- Select the Event Listeners tab.
- Click Add.
- Select the listener class from the new field in the Event Listener Classes pane.
Error Mapping
You can specify a mapping between the status code returned in an HTTP response or a Java programming language exception returned by any Web component and a Web resource (see Handling Errors). To set up the mapping,
- Select the WAR.
- Select the File Refs tab.
- Click Add in the Error Mapping pane.
- Enter the HTTP status code (see HTTP Responses) or fully-qualified class name of an exception in the Error/Exception field.
- Enter the name of a resource to be invoked when the status code or exception is returned. The name should have a leading forward slash
/.
Note: You can also define error pages for a JSP page contained in a WAR. If error pages are defined for both the WAR and a JSP page, the JSP page's error page takes precedence.
Filter Mapping
A Web container uses filter mapping declarations to decide which filters to apply to a request, and in what order (see Filtering Requests and Responses). The container matches the request Uniform Resource Identifier (URI) to a servlet as described in Specifying an Alias Path. To determine which filters to apply, it matches filter mapping declarations by servlet name or URL pattern. The order in which filters are invoked is the order in which filter mapping declarations that match a request URI for a servlet appear in the filter mapping list.
You specify a filter mapping in
deploytoolas follows:
- Select the WAR.
- Select the Filter Mapping tab.
- Add a filter.
- Click Edit Filter List.
- Click Add.
- Select the filter class.
- Enter a filter name.
- Add any filter initialization parameters.
- Click OK.
- Map the filter.
Component-Level Configuration
Initialization Parameters
To specify parameters that are passed to the Web component when it is initialized,
- Select the Web component.
- Select the Init. Parameters tab.
- Click Add to add a new parameter and value.
Specifying an Alias Path
When a request is received by a Web container, it must determine which Web component should handle the request. It does so by mapping the URL path contained in the request to a Web component. A URL path contains the context root (described in the section Context Root) and an alias path:
http://<host>:8000/context root/alias pathBefore a servlet can be accessed, the Web container must have at least one alias path for the component. The alias path must start with a
/and end with a string or a wildcard expression with an extension (*.jsp, for example). Since Web containers automatically map an alias path that ends with*.jsp, you do not have to specify an alias path for a JSP page unless you wish to refer to the page by a name other than its file name. In the example discussed in the section Updating Web Clients, the pagegreeting.jsphas an alias,/greeting, but the pageresponse.jspis referenced by its file name withingreeting.jsp.You set up the mappings for the servlet version of the Hello application using the Web component inspector as follows:
|
Home TOC Index |
|
Search
Feedback |