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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.