InfoCenter Home >
4: Developing applications >
4.2: Building Web applications >
4.2.1: Developing servlets >
4.2.1.3: Servlet content, examples, and samples >
4.2.1.3.3: Using page lists to avoid hard coding URLs >
4.2.1.3.3.1: Obtaining and using servlet XML configuration files (.servlet files) >
4.2.1.3.3.1.3: XML servlet configuration file syntax (.servlet syntax)

4.2.1.3.3.1.3: XML servlet configuration file syntax (.servlet syntax)

Each XML configuration file must be a well-formed XML document. The files are not validated against a Document Type Definition (DTD). This article describes the syntax, as illustrated by the example cited in Related information.

For the Application Server to use an XML servlet configuration file to load a servlet instance, the file must contain at least the code element. For a PageListServlet, the XML configuration file must contain at least the code element and the page-list element.

Although there is no DTD, it is recommended that all elements appear in the order shown in the example. The elements (also known as tags) are:

Tag Description
servlet The root element of an XML configuration file. The XMLServletConfig class automatically generates this element.
code The class name of the servlet (without the .class extension), even if the servlet is in a JAR file
description A user-defined description of the servlet
init-parameter The attributes of this element specify a name-value pair to be used as an initialization parameter. A servlet can have multiple initialization parameters, each within its own init-parameter element.
page-list Identifies the JavaServer pages to be called depending on the path information in the HTTP request. The page-list element can contain the following child elements:
  • default-page: Contains a uri element that specifies the location of the page to be loaded, if the HTTP request does not contain path information
  • error-page: Contains a uri element that specifies the location of the page to be loaded, if the handleError() method sets the request attribute "error"
  • page: Contains a uri element that specifies the location of the page to be loaded if the HTTP request contains the page name. A page-list element can contain multiple page elements.

Go to previous article: Using XMLServletConfig to create .servlet configuration files Go to next article: Example: XML servlet configuration file

 

 
Go to previous article: Using XMLServletConfig to create .servlet configuration files Go to next article: Example: XML servlet configuration file