Web Applications Overview

by Jeff Hunter, Sr. Database Administrator


What is a Web Application?

According to the Java servlet specification 2.2, a Web Application is a collection of servlets, html pages, images, classes and other resources that can be bundled and run on multiple containers from multiple vendors. What this really means is that a Web Application is a container that can hold any combination of the following list of objects:

One of the main characteristics of a Web Application is its relationship to the ServetContext. This relationship is controlled by the servlet container and guarantees that no two Web Applications will clash when accessing objects in the ServletContext.


Directory Structure of a Web Application

Take the example application "metaview". We would create a direction under <SERVER_ROOT> called metaview. If <SERVER_ROOT> is /u02/app/tomcat/webapps you would create the directory

# mkdir /u02/app/tomcat/webapps/metaview
The following table is a list of the directories that make up the web application along with description of each directory.

DIRECTORY DESCRIPTION
/metaview The root directory of the Web Application. All JSP and HTML files should be stored here. Keep in mind that you would create additional directories to better organize these HTML and JSP files. This would be true of a Web Application that contains many files.
/metaview/images Contains all graphics images (icons, images, graphics).
/metaview/WEB-INF Contains all resources related to the application that are not in the document root of the application. This is where you Web Application deployment descriptor (web.xml) is located. Note that the WEB-INF directory is not part of the public document. No files contained in this directory can be requested directly by the client.
/metaview/WEB-INF/classes Where servlet and utility classes are located.
/metaview/WEB-INF/lib Contains Java Archive files that the Web Application is dependant on. For example, this is where you would place a JAR file that contained a JDBC driver or JSP tag library.

NOTE: You can store compiled objects in both the /WEB-INF/classes and /WEB-INF/lib directories. Of these two, the class loader loads classes from the /classes directory first, followed by the JARs that are loaded in the /lib directory. If duplicate objects in both the /classes and /lib directories exist, the objects in the /classes directory take precedence.


Packaging a Web Application

Once the Web Application is complete, you need to package it for deployment. The standard method for packaging Web Applications is to use a Web Archive (WAR) file, which you create by using Java's archiving tool jar. An example of this would be to change to the root directory of your Web Application and type the following command:
# jar cvf metaview.war .



Last modified on: Saturday, 18-Sep-2010 18:14:02 EDT
Page Count: 3794