Use of URL Paths
Upon receipt of a client request, the Web container determines the Web application to which to forward it. The Web application selected must have the longest context path that matches the start of the request URL.
The matched part of the URL is the context path when mapping to servlets. The Web container next must locate the servlet to process the request, using the path mapping procedure described below.
The path used for mapping to a servlet is the request URL from the request object, minus the context path and the path parameters. The URL path mapping rules below are followed in sequence. The first successful match is used with no further matches attempted.
Procedure
- The container looks for an exact match of the path of the request to the path of the servlet. A successful match selects the servlet.
- The container recursively attempts to match the longest path-prefix. This is done by stepping down the path tree a directory at a time, using the ’/’ character as a path separator. The longest match determines the servlet selected.
- If the last segment in the URL path contains an extension (for example, jsp), the servlet container tries to match a servlet that handles requests for the extension. An extension is defined as the part of the last segment after the last ’.’ character
- If neither of the previous three rules result in a servlet match, the container tries to serve content appropriate for the resource requested. If a "default" servlet is defined for the application, it will be used. The container must use case-sensitive string comparisons for matching.
Copyright © 2022. Cloud Software Group, Inc. All Rights Reserved.