When you execute a web application, the server uses a context path setting to derive the path to the web application. For example, if the context path is /directives, then you can access a file named index.html under the web application's document base (root directory) using the URL http://host:port/directives/index.html.
You should set a context path for a web application if you plan to execute different web applications on the same server. Otherwise, files with the same name will overwrite files from other web applications. When you create a web application from the New Project wizard, the default context path is derived from the name of the project.
To set a web application's context path:
![]() |
When you change the Context Path in the Project Properties dialog box, the IDE updates the Tomcat Web Server's context descriptor (META-INF/context.xml) or the GlassFish application server's deployment descriptor (WEB-INF/glassfish-web.xml) to match. |
When the server receives the HTTP request, the server selects the web application to be processed by matching the longest possible prefix of the Request URI against all of the defined context paths. A host can have an unlimited number of unique context paths.