RequestDispatcher includes and support for consistent URL decoding.
Used by org.
and org. for path matching
and/or URI determination.
getLookupPathForRequest, jakarta.servlet.RequestDispatcher
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private String | |
| public static final UrlPathHelper | defaultInstance
Shared, read-only instance with defaults. |
| private static final Log | |
| public static final String | PATH_ATTRIBUTE
Name of Servlet request attribute that holds a
|
| public static final UrlPathHelper | rawPathInstance
Shared, read-only instance for the full, encoded path. |
| private boolean | |
| private boolean | |
| private boolean | |
| private static final String | WEBSPHERE_URI_ATTRIBUTE
Special WebSphere request attribute, indicating the original request URI. |
| pack-priv static volatile Boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private String | decodeAndCleanUriString(HttpServletRequest request, String uri)
Decode the supplied URI string and strips any extraneous portion after a ';'. |
| private String | |
| public MultiValueMap | Returns: the same Map or a new Map instancecurrent HTTP request request, MultiValueMap<String, String> the URI variables extracted from the URL path vars)Decode the given matrix variables via |
| public Map | Returns: the same Map or a new Map instancecurrent HTTP request request, Map<String, String> the URI variables extracted from the URL path vars)Decode the given URI path variables via |
| public String | Returns: the decoded Stringcurrent HTTP request request, String the String to decode source)Decode the given source string with a URLDecoder. |
| protected String | Returns: the encoding for the request (nevernull)current HTTP request request)Determine the encoding for the given request. |
| public String | Returns: the context pathcurrent HTTP request request)Return the context path for the given request, detecting an include request URL if called within a RequestDispatcher include. |
| protected String | |
| public String | Returns: the lookup pathcurrent HTTP request request, String the request attribute that holds the lookupPath name)
Deprecated
as of 5.3 in favor of using
Variant of resolveAndCacheLookupPath(HttpServletRequest) and
getResolvedLookupPath(ServletRequest).
getLookupPathForRequest(HttpServletRequest) that
automates checking for a previously computed lookupPath saved as a
request attribute.
|
| public String | Returns: the lookup pathcurrent HTTP request request)Return the mapping lookup path for the given request, within the current servlet mapping if applicable, else within the web application. |
| public String | Returns: the context pathcurrent HTTP request request)Return the context path for the given request, detecting an include request URL if called within a RequestDispatcher include. |
| public String | Returns: the query stringcurrent HTTP request request)Return the query string part of the given request's URL. |
| public String | |
| public String | Returns: the servlet pathcurrent HTTP request request)Return the servlet path for the given request, detecting an include request URL if called within a RequestDispatcher include. |
| public String | Returns: the path within the web applicationcurrent HTTP request request)Return the path within the web application for the given request. |
| public String | Returns: the path within the servlet mapping, or ""current HTTP request request)Return the path within the servlet mapping for the given request, i.e. the part of the request's URL beyond the part that called the servlet, or "" if the whole URL has been used to identify the servlet. |
| protected String | Returns: the path within the servlet mapping, or ""current HTTP request request, String a precomputed path within the application pathWithinApp)Return the path within the servlet mapping for the given request, i.e. the part of the request's URL beyond the part that called the servlet, or "" if the whole URL has been used to identify the servlet. |
| private String | getRemainingPath(String requestUri, String mapping, boolean ignoreCase)
Match the given "mapping" to the start of the "requestUri" and if there is a match return the extra part. |
| public String | Returns: the request URIcurrent HTTP request request)Return the request URI for the given request, detecting an include request URL if called within a RequestDispatcher include. |
| public static String | Returns: the previously resolved lookupPaththe current request request)Return a previously |
| private static String | |
| public String | Returns: the servlet pathcurrent HTTP request request)Return the servlet path for the given request, regarding an include request URL if called within a RequestDispatcher include. |
| private boolean | ignoreServletPath(HttpServletRequest request)
Whether we can ignore the servletPath and pathInfo for mapping purposes, which is the case when we can establish that the Servlet is not mapped by servletPath prefix. |
| public boolean | |
| private String | |
| public String | Returns: the updated URI stringthe request URI string to remove ";" content from requestUri)Remove ";" (semicolon) content from the given request URI if the removeSemicolonContent property is set to "true". |
| private static String | |
| public String | Returns: the resolved paththe current request request)
|
| public void | setAlwaysUseFullPath(boolean alwaysUseFullPath)
Whether URL lookups should always use the full path within the current
web application context, i.e. within
|
| public void | setDefaultEncoding(String
the character encoding to use defaultEncoding)Set the default character encoding to use for URL decoding. |
| private void | |
| public void | setRemoveSemicolonContent(boolean removeSemicolonContent)
Set if ";" (semicolon) content should be stripped from the request URI. |
| public void | setUrlDecode(boolean urlDecode)
Whether the context path and request URI should be decoded -- both of which are returned undecoded by the Servlet API, in contrast to the servlet path. |
| public boolean | shouldRemoveSemicolonContent()
Whether configured to remove ";" (semicolon) content from the request URI. |
| private boolean |
| alwaysUseFullPath | back to summary |
|---|---|
| private boolean alwaysUseFullPath | |
| defaultEncoding | back to summary |
|---|---|
| private String defaultEncoding | |
| defaultInstance | back to summary |
|---|---|
| public static final UrlPathHelper defaultInstance Shared, read-only instance with defaults. The following apply:
| |
| logger | back to summary |
|---|---|
| private static final Log logger | |
| PATH_ATTRIBUTE | back to summary |
|---|---|
| public static final String PATH_ATTRIBUTE Name of Servlet request attribute that holds a
| |
| rawPathInstance | back to summary |
|---|---|
| public static final UrlPathHelper rawPathInstance Shared, read-only instance for the full, encoded path. The following apply:
| |
| readOnly | back to summary |
|---|---|
| private boolean readOnly | |
| removeSemicolonContent | back to summary |
|---|---|
| private boolean removeSemicolonContent | |
| urlDecode | back to summary |
|---|---|
| private boolean urlDecode | |
| WEBSPHERE_URI_ATTRIBUTE | back to summary |
|---|---|
| private static final String WEBSPHERE_URI_ATTRIBUTE Special WebSphere request attribute, indicating the original request URI. Preferable over the standard Servlet 2.4 forward attribute on WebSphere, simply because we need the very first URI in the request forwarding chain. | |
| websphereComplianceFlag | back to summary |
|---|---|
| pack-priv static volatile Boolean websphereComplianceFlag
| |
| UrlPathHelper | back to summary |
|---|---|
| public UrlPathHelper() | |
| checkReadOnly | back to summary |
|---|---|
| private void checkReadOnly() | |
| decodeAndCleanUriString | back to summary |
|---|---|
| private String decodeAndCleanUriString(HttpServletRequest request, String uri) Decode the supplied URI string and strips any extraneous portion after a ';'. | |
| decodeInternal | back to summary |
|---|---|
private String decodeInternal(HttpServletRequest request, String source)
| |
| decodeMatrixVariables | back to summary |
|---|---|
| public MultiValueMap Decode the given matrix variables via
| |
| decodePathVariables | back to summary |
|---|---|
| public Map Decode the given URI path variables via | |
| decodeRequestString | back to summary |
|---|---|
| public String decodeRequestString(HttpServletRequest request, String source) Decode the given source string with a URLDecoder. The encoding will be taken from the request, falling back to the default "ISO-8859-1". The default implementation uses
| |
| determineEncoding | back to summary |
|---|---|
| protected String determineEncoding(HttpServletRequest request) Determine the encoding for the given request. Can be overridden in subclasses. The default implementation checks the request encoding, falling back to the default encoding specified for this resolver.
| |
| getContextPath | back to summary |
|---|---|
| public String getContextPath(HttpServletRequest request) Return the context path for the given request, detecting an include request URL if called within a RequestDispatcher include. As the value returned by
| |
| getDefaultEncoding | back to summary |
|---|---|
| protected String getDefaultEncoding() Return the default character encoding to use for URL decoding. | |
| getLookupPathForRequest | back to summary |
|---|---|
| public String getLookupPathForRequest(HttpServletRequest request, String name)
Deprecated as of 5.3 in favor of using
Variant of
| |
| getLookupPathForRequest | back to summary |
|---|---|
| public String getLookupPathForRequest(HttpServletRequest request) Return the mapping lookup path for the given request, within the current servlet mapping if applicable, else within the web application. Detects include request URL if called within a RequestDispatcher include.
| |
| getOriginatingContextPath | back to summary |
|---|---|
| public String getOriginatingContextPath(HttpServletRequest request) Return the context path for the given request, detecting an include request URL if called within a RequestDispatcher include. As the value returned by
| |
| getOriginatingQueryString | back to summary |
|---|---|
| public String getOriginatingQueryString(HttpServletRequest request) Return the query string part of the given request's URL. If this is a forwarded request, correctly resolves to the query string of the original request.
| |
| getOriginatingRequestUri | back to summary |
|---|---|
| public String getOriginatingRequestUri(HttpServletRequest request) Return the request URI for the given request. If this is a forwarded request, correctly resolves to the request URI of the original request. | |
| getOriginatingServletPath | back to summary |
|---|---|
| public String getOriginatingServletPath(HttpServletRequest request) Return the servlet path for the given request, detecting an include request URL if called within a RequestDispatcher include.
| |
| getPathWithinApplication | back to summary |
|---|---|
| public String getPathWithinApplication(HttpServletRequest request) Return the path within the web application for the given request. Detects include request URL if called within a RequestDispatcher include.
| |
| getPathWithinServletMapping | back to summary |
|---|---|
| public String getPathWithinServletMapping(HttpServletRequest request) Return the path within the servlet mapping for the given request, i.e. the part of the request's URL beyond the part that called the servlet, or "" if the whole URL has been used to identify the servlet.
| |
| getPathWithinServletMapping | back to summary |
|---|---|
| protected String getPathWithinServletMapping(HttpServletRequest request, String pathWithinApp) Return the path within the servlet mapping for the given request, i.e. the part of the request's URL beyond the part that called the servlet, or "" if the whole URL has been used to identify the servlet. Detects include request URL if called within a RequestDispatcher include. E.g.: servlet mapping = "/*"; request URI = "/test/a" → "/test/a". E.g.: servlet mapping = "/"; request URI = "/test/a" → "/test/a". E.g.: servlet mapping = "/test/*"; request URI = "/test/a" → "/a". E.g.: servlet mapping = "/test"; request URI = "/test" → "". E.g.: servlet mapping = "/*.test"; request URI = "/a.test" → "".
| |
| getRemainingPath | back to summary |
|---|---|
| private String getRemainingPath(String requestUri, String mapping, boolean ignoreCase) Match the given "mapping" to the start of the "requestUri" and if there is a match return the extra part. This method is needed because the context path and the servlet path returned by the HttpServletRequest are stripped of semicolon content unlike the requestUri.
| |
| getRequestUri | back to summary |
|---|---|
| public String getRequestUri(HttpServletRequest request) Return the request URI for the given request, detecting an include request URL if called within a RequestDispatcher include. As the value returned by The URI that the web container resolves should be correct, but some containers like JBoss/Jetty incorrectly include ";" strings like ";jsessionid" in the URI. This method cuts off such incorrect appendices.
| |
| getResolvedLookupPath | back to summary |
|---|---|
| public static String getResolvedLookupPath(ServletRequest request) Return a previously
| |
| getSanitizedPath | back to summary |
|---|---|
| private static String getSanitizedPath(final String path) Sanitize the given path. Uses the following rules:
| |
| getServletPath | back to summary |
|---|---|
| public String getServletPath(HttpServletRequest request) Return the servlet path for the given request, regarding an include request URL if called within a RequestDispatcher include. As the value returned by
| |
| ignoreServletPath | back to summary |
|---|---|
| private boolean ignoreServletPath(HttpServletRequest request) Whether we can ignore the servletPath and pathInfo for mapping purposes, which is the case when we can establish that the Servlet is not mapped by servletPath prefix. | |
| isUrlDecode | back to summary |
|---|---|
| public boolean isUrlDecode() Whether to decode the request URI when determining the lookup path.
| |
| removeJsessionid | back to summary |
|---|---|
| private String removeJsessionid(String requestUri) | |
| removeSemicolonContent | back to summary |
|---|---|
| public String removeSemicolonContent(String requestUri) Remove ";" (semicolon) content from the given request URI if the removeSemicolonContent property is set to "true". Note that "jsessionid" is always removed. | |
| removeSemicolonContentInternal | back to summary |
|---|---|
| private static String removeSemicolonContentInternal(String requestUri) | |
| resolveAndCacheLookupPath | back to summary |
|---|---|
| public String resolveAndCacheLookupPath(HttpServletRequest request)
| |
| setAlwaysUseFullPath | back to summary |
|---|---|
| public void setAlwaysUseFullPath(boolean alwaysUseFullPath) Whether URL lookups should always use the full path within the current
web application context, i.e. within
If set to false the path within the current servlet mapping is used instead if applicable (i.e. in the case of a prefix based Servlet mapping such as "/myServlet/*"). By default this is set to "false". | |
| setDefaultEncoding | back to summary |
|---|---|
| public void setDefaultEncoding(String defaultEncoding) Set the default character encoding to use for URL decoding. Default is ISO-8859-1, according to the Servlet spec. If the request specifies a character encoding itself, the request
encoding will override this setting. This also allows for generically
overriding the character encoding in a filter that invokes the
| |
| setReadOnly | back to summary |
|---|---|
| private void setReadOnly() Switch to read-only mode where further configuration changes are not allowed. | |
| setRemoveSemicolonContent | back to summary |
|---|---|
| public void setRemoveSemicolonContent(boolean removeSemicolonContent) Set if ";" (semicolon) content should be stripped from the request URI. Default is "true". | |
| setUrlDecode | back to summary |
|---|---|
| public void setUrlDecode(boolean urlDecode) Whether the context path and request URI should be decoded -- both of which are returned undecoded by the Servlet API, in contrast to the servlet path. Either the request encoding or the default Servlet spec encoding (ISO-8859-1) is used when set to "true". By default this is set to true. Note Be aware the servlet path will not match when
compared to encoded paths. Therefore use of | |
| shouldRemoveSemicolonContent | back to summary |
|---|---|
| public boolean shouldRemoveSemicolonContent() Whether configured to remove ";" (semicolon) content from the request URI. | |
| shouldRemoveTrailingServletPathSlash | back to summary |
|---|---|
| private boolean shouldRemoveTrailingServletPathSlash(HttpServletRequest request) | |