Home TOC |
Search
Feedback |
Configuring Web Components
The following sections describe the web component 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 security parameters, see Security.
Application-Level Configuration
Context Root
A context root is a path that gets mapped to the document root of a J2EE application. If the entry URL of an application is the same as the base of the web server's URL namespace (for example http://<host>:8000), the context root is an empty string. If your application's context root is catalog, then a request URL such as http://<host>:8000/catalog/index.html will retrieve the file index.html from the application's document root.
To specify the context root for the hello1 application in deploytool:
- Select the hello1 application.
- Select the Web Context tab and enter hello1 in the Context Root field.
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). You can specify initialization parameters that are passed to the context as follows:
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 Ref's, Resource Env. Ref's or Resource Ref's tab.
- Click Add in the panel to add a new reference.
Event Listeners
To add an event listener class (described in Monitoring 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 panel.
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 another web component or resource (see Handling Errors). To set up the mapping:
- Select the WAR.
- Select the File Ref's tab.
- Click Add in the Error Mapping panel.
- 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 '/'.
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 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 the deploytool as 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
You can specify parameters that are passed to the web component when it is initialized as follows:
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 Context Root) and an alias path:
http://<host>:8000/context root/alias pathTherefore, before your web component can be accessed, the web container must have 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). Web containers automatically map an alias path that ends with *.jsp to a servlet that transforms and compiles JSP pages, unless an application specifies otherwise.
You set up the mappings for the servlet version of the Hello application using the web component inspector as follows:
Home TOC |
Search
Feedback |