5.5. Initializing and Preloading Servlets and JSP Pages

This section discusses methods for controlling the startup behavior of servlets and JSP pages. In particular, it explains how you can assign initialization parameters and how you can change the point in the server life cycle at which servlets and JSP pages are loaded.

Assigning Servlet Initialization Parameters

You provide servlets with initialization parameters by means of the init-param element, which has param-name and param-value subelements. For instance, in the following example, if the InitServlet servlet is accessed by means of its registered name (InitTest), it could call getServletConfig().getInitParameter("param1") from its init method to get "Value 1" and getServletConfig().getInitParameter("param2") ...

Get More Servlets and JavaServer Pages™ 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.