Previous Topic Next topic Print topic


The Servlet Deployment Descriptor

The deployment descriptor is the file used by the servlet container to define which servlets match up with which URLs. It also defines which servlet or resource provides the landing page for the root of the service.

If it doesn't already exist, create the file web.xml in the JSPBookDemo project:
  1. Expand WebContent, right-click the WEB-INF folder in Project Explorer, and then click New > File.
  2. Type web.xml in the File name field, and click Finish.
    Note: If Finish is greyed out, check for the message 'web.xml' already exists, and click Cancel. Expand WEB-INF to locate the file.
  3. Open the file, and ensure it is in source mode by clicking the Source tab at the bottom left side of the XML Editor window.
  4. Overwrite the skeleton contents of the file with the web.xml file that you downloaded previously (the file is in C:\myfiles\COBOL_JSP_DEMO_2_2_SRC\JSPBookDemo\WebContent\WEB-INF). Perform this task even if the file exists.
  5. Save the file.
This is a deployment descriptor with the following elements:
<web-app>
Defines the specific version of the servlet API in use.
<display-name>
Defines the internal name of this web application that will appear in the servlet container management system.
<servlet>
Binds a name to a particular servlet class, in this case BookServlet.
<servlet-mapping>
Binds a particular servlet to a URL from the root of the servlet. As such, any call to localhost:8080/JSPBookDemo/view, for example, is directed to BookServlet.
<welcome-file-list>
Defines a set of files to use as the landing page for the servlet. In this case, the view is set to be the landing page.
Previous Topic Next topic Print topic