Skip to content

Configuration

Context Path

Each web application is addressed with a context path. * To access a component or file in the web application from a browser, you must include the context path in the request URL.

Context Path

  • The context path is determined when the application is deployed.
  • A web container can contain a "default" application, which has an empty context path.

You must organize your web application using a specific directory structure.

Web App Directories

Web content (files users can retrieve in their browsers) by default goes in src/main/webapp.

  • The web content directory acts as the document root for your application.

WebContent

  • Put your JSP, HTML, and other supporting files here.

  • You can use subdirectories to organize your application.

  • Store your application files in a subdirectory named WEB-INF.

WEB-INF

  • Place the web.xml configuration file here.

  • WEB-INF is not accessible via the web server.

web.xml Deployment Descriptor

web.xml is a special file inside WEB-INF/ which connects the Java Servlet to the Web Container.

WEB.xml

Java Files

In Eclipse, Java files belong in a Source Folder, named src/main/java by default.

Source folder

Practice Exercise

When the application is deployed, class files are copied to /WEB-INF/classes. Libraries go in /WEB-INF/lib.

Run As->Run on Server deploys the web app to the Tomcat installation directory on your computer.


Prev -- Up -- Next