What is a web application (or "webapp")?

Alex Chaffee

A Web Application (or "webapp") is a concept that was introduced in the Servlet Specification version 2.2. [2.1?] You should definitely read the spec for the full story. From the spec (chapter 9):

A web application is a collection of servlets, html pages, classes, and other resources that can be bundled and run on multiple containers from multiple vendors. A web application is rooted at a specific path within a web server. For example, a catalog application could be located at http:// www.mycorp.com/catalog. All requests that start with this prefix will be routed to the ServletContext which represents the catalog application.

A servlet container can also establish rules for automatic generation of web applications. For example a ~user/ mapping could be used to map to a web application based at /home/user/ public_html/.


A web application exists as a structured hierarchy of directories. The root of this hierarchy serves as a document root for serving files that are part of this context. For example, for a web application located at /catalog in a web server, the index.html file located at the base of the web application hierarchy can be served to satisfy a request to /catalog/index.html.

A special directory exists within the application hierarchy named "WEB-INF". This directory contains all things related to the application that aren't in the document root of the application. It is important to note that the WEB-INF node is not part of the public document tree of the application. No file contained in the WEB-INF directory may be served directly to a client.

The contents of the WEB-INF directory are:

  • /WEB-INF/web.xml deployment descriptor
  • /WEB-INF/classes/* directory for servlet and utility classes. The classes in this directory are used by the application class loader to load classes from.
  • /WEB-INF/lib/*.jar area for Java ARchive files which contain servlets, beans, and other utility classes useful to the web application. All such archive files are used by the web application class loader to load classes from.

<h3>Sample Web Application Directory Structure</h3>

Illustrated here is a listing of all the files in a sample web application: