5.3.2 Types of URL patterns and priority of applicable patterns
This section describes the types of URL patterns that you can specify for URL mapping of the Redirector and the priority of applicable patterns.
- Organization of this subsection
(1) Types of URL patterns
You can specify the following four types of URL patterns for the URL mapping of the redirector:
-
Complete path specification
This is a completely matching pattern.
- URL format:
-
/path
When specifying only the route, use "/".
- Characters you can specify in /path:
-
Specify a string having at least one of the following characters:
Single-byte alphanumeric characters, "/", "*", "-", ".", "_", "~", "!", "$", "&", " '", "(", ")", "+", ",", "=", ":", "@"
- Example:
-
When the URL pattern is /examples/jsp/index.jsp, and the URL is /examples/jsp/index.jsp, it indicates a match.
-
Path specification
In this pattern, the paths are matching.
- URLformat:
-
/path/*
When specifying all requests, use /*.
- Characters you can specify in /path:
-
Specify a string having at least one of the following characters:
Single-byte alphanumeric characters, "/", "*", "-", ".", "_", "~", "!", "$", "&", " '", "(", ")", "+", ",", "=", ":", "@"
- Example:
-
When the URL pattern is /examples/*, and the URL is /examples/jsp/index.jsp, it indicates a match.
-
Extension specification
In this pattern, the extensions are matching. This pattern is applicable to all the hierarchies below the specified path.
- URL format:
-
/path/*.extension
When specifying all the paths, use /*.extension.
- Characters you can specify in path and extension:
-
Specify a string having at least one of the following characters:
Single-byte alphanumeric characters, "/", "*", "-", ".", "_", "~", "!", "$", "&", " '", "(", ")", "+", ",", "=", ":", "@"
- Example:
-
When the URL pattern is /examples/*.jsp, and the URL is /examples/jsp/index.jsp, it indicates a match.
-
Suffix specification
In this pattern, suffixes are matching. This pattern is applicable to all the hierarchies below the specified path.
- URL format:
-
/path/*suffix
When specifying all the paths, use /*suffix.
- Characters you can specify in path and suffix:
-
Specify a string having at least one of the following characters:
Single byte alphanumeric characters, "/", "*", "-", ".", "_", "~", "!", "$", "&", " '", "(", ")", "+", ",", "=", ":", "@"
- Example:
-
When the URL pattern is /examples/servlet/*Servlet, and the URL is /examples/servlet/HelloServlet, it indicates a match.
- Important note
-
The following are the notes on specifying a URL pattern:
-
A URL pattern must not begin with anything but "/". In Windows, if you specify a character other than "/", the KDJE41012-E message is output and the mapping is ignored. In any other OS, a message is displayed and Cosminexus HTTP Server fails to start.
-
A "*", when used as a wildcard, cannot be specified before the /* in a URL pattern. If you specify anything other than "/" just before the first "*" in a URL pattern, the URL pattern is treated as a Complete path specification and /* is not treated as a wildcard even if it is a part of the URL.
-
Do not describe multiple mappings of the same URL pattern. The behavior in case you specify multiple mappings, is as follows.
The former URL pattern mapping is used in the Complete path specification and the Path specification. The latter mapping is used in the case of Extension specification and Suffix specification.
-
You must use only valid values in path, extension, and suffix. If you use an invalid character in a URL pattern, some types of characters might not be forwarded to the Web container.
-
The string length of extension or suffix must be at least one character long. If the length is shorter than one character, the Extension specification outputs the KDJE41041-W message, and the mapping is ignored. In the Suffix specification, the value that you specify is treated as a URL pattern of the Path specification.
-
(2) Priority of applicable patterns
Among the mapping to these four URL patterns, the URL pattern with the highest priority is Complete path specification. When the URL does not match with Complete path specification, path matching is judged in the following order, and the applicable URL pattern is decided:
-
When the URL does not match with Complete path specification
The longest matching URL pattern from among Path specification, Extension specification, and Suffix specification is applied. Longest match refers to the longest matching URL from the beginning ("/") until the high order path of "*".
The URL in which the following two mappings are defined is illustrated below as an example:
- Mapping definition:
-
/examples/* worker1
/examples/jsp/* worker2
In this case, when the URL is /examples/jsp/index.jsp, the mapping of worker2 is applied, and when the URL is /examples/test/index.jsp, the mapping of worker1 is applied.
-
In addition to the conditions of 1, when multiple longest matching Path specification, Extension specification, and Suffix specification URL patterns are present
Extension specification or Suffix specification is given priority over Path specification.
The URL in which the following two mappings are defined is illustrated below as an example:
- Mapping definition:
-
/examples/jsp/* worker1
/examples/jsp/*.jsp worker2
In this case, when the URL is /examples/jsp/index.jsp, the mapping of worker2 is applied, and when the URL is /examples/jsp/test.html, the mapping of worker1 is applied.
-
In addition to the conditions of 1 and 2, when multiple longest matching Extension specification and Suffix specification URL patterns are present
The URL pattern specified later is given priority.
The URL in which the following two mappings are defined is illustrated below as an example:
- Mapping definition:
-
/examples/*.jsp worker1
/examples/*jsp worker2
When URL is specified in this order, the mapping of worker2 is applied when the URL is /examples/jsp/index.jsp.
- Important note
-
You must note the following points when judging the priority of applicable patterns:
-
If a request URL includes a query (string after a "?" mark in the URL), the query part is not used when comparing with the URL pattern.
Example:
If the request URL is /examples/jsp/index.jsp?query=foo, the URL used for comparison is /examples/jsp/index.jsp.
-
If a request URL includes a parameter (string from a semicolon (;)), the parameter part is not used when comparing with the URL pattern.
Example:
If the request URL is /examples/jsp/index.jsp;jsessionid=0000, the URL used for comparison is /examples/jsp/index.jsp.
-
A request URL path is first normalized and then the URL is compared with the URL pattern to judge whether both the URLs match.
Example:
If a request URL is /examples/../examples/./jsp//index.jsp, the URL used for comparison is /examples/jsp/index.jsp.
-
A URL pattern is never normalized. Therefore, a URL pattern that includes ./ or ../ does not match with the request URL.
-
In Windows, an extension of a URL pattern specified in the Extension specification is not case sensitive.
-