to the main page about the tutorial  INTERACTIVE WEB SERVICES WITH JAVA back up next

Deployment

A Servlet Web application is structured in a directory:

myapplication/ contains auxiliary files (e.g. HTML, GIF, CSS, JSP files), can be in sub-directories
myapplication/WEB-INF/ contains deployment descriptor, web.xml
myapplication/WEB-INF/classes/ contains Servlet class files (in appropriate sub-directories, if non-default package names)
myapplication/WEB-INF/lib/ contains extra jar files

Using the normal jar tool, a complete Web application can be wrapped into a portable Web Archive (.war).


The deployment descriptor: web.xml

provides control of:

Example:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
          PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
          "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <!-- assign Name and Initialization Parameters to Manager Servlet -->
  <servlet>
    <servlet-name>Manager</servlet-name>
    <servlet-class>org.apache.catalina.servlets.ManagerServlet</servlet-class>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
  </servlet>

  <!-- define the Manager Servlet mapping -->
  <servlet-mapping>
    <servlet-name>Manager</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>

  <!-- define a Security Constraint on this application -->
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Entire Application</web-resource-name>
      <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
       <role-name>manager</role-name>
    </auth-constraint>
  </security-constraint>

  <!-- define the Login Configuration for this application -->
  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>Tomcat Manager Application</realm-name>
  </login-config>
</web-app>

- for simple applications, the default deployment descriptor is sufficient.

Default mapping from URLs to files:

Warning: if not using the default deployment descriptor, make sure that the default URL mapping (the "invoker servlet") is deactivated (using servlet-mapping)!

back COPYRIGHT © 2002-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH next