19.5. An Example Using Initialization Parameters

Listing 19.6 shows a servlet that, when initialized, reads the message and repeats initialization parameters. Figure 19-3 shows the result when message is Shibboleth, repeats is 5, and the servlet is registered under the name ShowMsg. Listing 19.7 shows the XML configuration file used with Tomcat 3 to obtain the result of Figure 19-3, and Listing 19.8 shows the configuration file used with the JSWDK. Servers compliant with the 2.2 servlet specification use the same file format (web.xml) as Tomcat, albeit sometimes with a graphical user interface to generate it.

Figure 19-3. The ShowMessage servlet, registered under the name ShowMsg and supplied with server-specific initialization parameters.

Get Core Web Programming, Second Edition 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.