Directory Structure

Every web application has the same directory structure:
  • The application has its own directory under tomcat/webapps.
  • This directory is known as the document root directory.
  • The WEB-INF directory goes in the document root directory.
  • The classes directory goes in the WEB-INF directory.
  • The lib directory goes in the WEB-INF directory.
Certain files go in particular directories:
  • JSP and static files (*.html, *.gif, etc.) go in the document root directory.
  • Other files go in the WEB-INF directory, which is hidden from the client.
  • The web.xml deployment descriptor goes in the WEB-INF directory
  • Java classes go in the classes directory, or its sub directories.
  • Jar files go in the lib directory.
Servlet containers such as Tomcat will automatically:
  • Read the deployment descriptors on startup.
  • Discover lib/JAR files and add them to the classpath.
  • Reload Java classes whenever their timestamp changes.