Home
| | Sitemap
||Page number :14
Programmer's Guide Nokia WAP Server API 1.1 page 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
previous || guide home || next
5.6 Servlets working together
A servlet can be in various roles in a complete WAP service. As discussed earlier, a servlet might perform pre-processing of WAP terminals' requests that will be forwarded either to another servlet or to an origin server. Alternatively, a servlet might perform post-processing of data returned by an origin server or another servlet in the Nokia WAP Server. Thus, servlets could serve e.g. the following practical purposes:
- A servlet might pre-process the WAP terminal's request in order to check e.g. the security class of the request before the request is forwarded to any other servlet or origin server.
- A servlet might incorporate some information (such as MSISDN number or type of connection) from the WAP Service API's interfaces to the HTTP request that will be forwarded to the origin server.
- A servlet might filter the origin server's response based on specific rules (e.g. to optimise the content for a specific terminal)
- A servlet might monitor the service and register the AckListerner interface in order to verify the delivery of the response (for creating accurate billing information or for ensuring some specific business logic).
Depending on the application's needs, various techniques can be used to link servlets to work together or to perform above type of filtering for terminals' requests or origin servers' responses:
Servlets in the Nokia WAP Server
- Servlet chaining. The Nokia WAP Server supports servlet chaining, which is an easy way to link several servlets to process a WAP terminal's request.
- MIME type mapping. The Nokia WAP Server supports mapping of MIME types to specific servlets to perform post-processing of predefined content types returned by e.g. another servlet or origin server.
- Locating other servlets via ServletContext. Servlets can locate other servlets via Java Servlet API's ServletContext to perform specific tasks.
- Locating server extensions. Finally, servlets can utilise server extensions, which are servlets implemented by the developer to enhance the Nokia WAP Server's functionality to serve specific needs.
The following sections describe the techniques in further detail.
5.6.1 Servlet chaining
The Nokia WAP Server supports servlet chaining, which provides an easy means for passing the output of one servlet to another servlet as input. The output of the last servlet in the chain is sent back to the terminal as a response to the terminal's request. As illustrated in the picture below, a servlet chain might include pre-processing of the requests, fetching information from the origin server and post-processing of the origin server's response. All of the servlets in the chain can be mapped to a single URL.
Nokia WAP Server
Servlet chaining: an output from one servlet is passed as input to another servlet.
The Nokia WAP Server does not provide an administration interface for configuring servlet chains, but you can easily configure them by editing the configuration files located in the [installation directory]\config directory.
| Configuration file | Description |
| Servlets.config | Defines the loaded servlets and their initialisation parameters. All these definitions can be configured from the Nokia WAP Server Manager. Thus, editing this file is not recommended as the servlets can be created and configured via the Nokia WAP Server Manager. |
| UrlMappings.config | Defines the URLs mapped to servlets and servlet chains. Note: URL mappings to a single servlet can be configured from the Nokia WAP Server Manager, but file editing is needed for the servlet chaining. |
Servlets in the Nokia WAP Server
Mapping URLs to servlet chains by editing the UrlMappings.config file
The following syntax can be used for mapping URLs to servlets or servlet chains. However, mapping URLs to a single servlet can be done via the Nokia WAP Server Manager, the management user interface of the Nokia WAP Server, and thus editing the file is needed only when mapping URLs to servlet chains.
Syntax:
urlmap.total=[total number of the url mappings] urlmap.[number].name=[servlet name] urlmap.[number].url=[url mapping]
Example:
urlmap.total=4 urlmap.1.name=FileServlet urlmap.1.url=http\://yourdomain/file/ urlmap.2.name=HelloWorld urlmap.2.url=http\://yourdomain/helloworld/
urlmap.3.name=FilterSample,HeaderSample urlmap.3.url=http\://yourdomain/myfirstchain/
urlmap.4.name=HTTP Client urlmap.4.url=http\://
5.6.2 Mapping servlets to handle specific MIME types
A servlet can be mapped to handle particular MIME types returned by another servlet or an origin server. A typical example of the use of the MIME type mapping is e.g. conversion of text/html to wml so that the response that is of the text/html MIME type is automatically directed to a servlet that converts the content to wml. The same approach can also be used for e.g. converting various image formats to the wbmp format by using appropriate image converters.
Defining mappings for MIME types by editing the MimeTypeMappings.config file
Mapping specific MIME types to an appropriate filter (servlet) can be done by editing the MimeTypeMappings.config file in the [installation directory]\config directory.
| Configuration file | Description |
| MimeTypeMappings.config | Defines the MIME types mapped to appropriate servlets. In the Nokia WAP Server 1.1 release, MIME types can be configured only by editing this file (not via the management user interface). The following syntax must be used. |
Programmer's Guide Nokia WAP Server API 1.1 page 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
previous || guide home || next