SPRING CONCEPTS

Application context path

Spring Concepts / Application context path

The context path identifies a deployed application within a server.

Understand the idea

The server can host multiple applications on one port. A request first identifies the application, then the route inside it. Deploying todo-servlet-jsp.war normally uses /todo-servlet-jsp as its context path.

A concrete example

/todo-servlet-jsp/todos/new
 context path     route

In the application

Redirects use getContextPath(); JSP c:url adds the context path to application-relative URLs.

A hard-coded /todos link points at the server root unless you account for the deployment context.

Related concepts

Read the official documentation ↗
Java 21 · Spring Boot 4.1.1 · Edupoly