5.6 EXAMPLE—READ ENVIRONMENT PARAMETERS

There are several environmental parameters that are available to the Servlet. Some of them are set by the programmer and the rest are available in the environment. Take a look at this program which prints out these variables.

First, let us see the parameters. There is something interesting—note the Inititalization Parameters.

The XML listing is shown below (Figure 5.16) for reference. Note the initial parameter set within the <init-param> set of tags (lines 6–9). The initial parameter is defined as name-value pairs; there can be many of them, but in this example there is only one defined (THEME:FORMAL).

 

 

Fig. 5.15 Web.xml configuration including an init parameter

 

 

 

Fig. 5.16 Web.xml file (myEnv) ...

Get Web Technology: Theory and Practice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.