Tomcat - Structure of the WebArchiveYou develop your web application within a specifi ed directory structure so that it can be archived and deployed on Tomcat 7. All servlets, classes, static fi les, and other resources belonging to a web application are organized under a directory hierarchy. The root of this hierarchy defi nes the document root of your web application. All fi les under this root directory can be served to the client, except for fi les under the special directory WEB-INF, located under the root directory. The name of your web application is used to resolve requests for components of the application.
Always place private fi les (fi les which are not required to serve to the
client) in the WEB-INF directory, under the root directory. All fi les
under WEB-INF are private, and are not served to the client.
<servlet>
<servlet-name>classB</servlet-name> <servlet-class>class.classB</servlet-class> </servlet> In the previous snippet, we are mapping the name to the servlet class (when Tomcat 7 starts, it will create an object of the class and map it to the name we have provided in the servlet-name fi eld).
classB =new class.classB ()
<servlet-mapping> <servlet-name> classB </servlet-name> Archive Files In most production environments, you receive a deployment unit as an archive fi le from the developer. An archive fi le is a single fi le that contains all of an application or module's classes, static fi les, directories, and deployment descriptor fi les. Archive fi les are typically created by using the JAR utility or Ant JAR tool. Deployment units that are packaged using the JAR utility have a specifi c fi le extension depending on the type, as explained in the following points:
An exploded archive directory contains the same fi les and directories as a JAR archive. However, the fi les and directories reside directly in your fi lesystem and are not packaged into a single archive fi le with the JAR utility. A deployment unit should be deployed as an exploded archive directory, rather than a single archive fi le, in the following circumstances:
The deployment tools provide support for performing these common deployment operations:
An application becomes unavailable to clients during undeployment.
The Tomcat 7 server doesn't guarantee the operation of the application
and deployment task if there is an access from the client at this time.
|