Package com.google.inject.servlet
Class ServletUtils
java.lang.Object
com.google.inject.servlet.ServletUtils
Some servlet utility methods.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Accumulates byte sequences while decoding strings, and encodes them into a StringBuilder. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final com.google.common.base.Joiner
private static final com.google.common.base.Splitter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static String
getContextRelativePath
(javax.servlet.http.HttpServletRequest request) Gets the context path relative path of the URI.private static String
lenientDecode
(String string, Charset encoding, boolean decodePlus) Percent-decodes a US-ASCII string into a Unicode string.(package private) static String
normalizePath
(String path) Normalizes a path by unescaping all safe, percent encoded characters.
-
Field Details
-
SLASH_SPLITTER
private static final com.google.common.base.Splitter SLASH_SPLITTER -
SLASH_JOINER
private static final com.google.common.base.Joiner SLASH_JOINER
-
-
Constructor Details
-
ServletUtils
private ServletUtils()
-
-
Method Details
-
getContextRelativePath
Gets the context path relative path of the URI. Returns the path of the resource relative to the context path for a request's URI, or null if no path can be extracted.Also performs url decoding and normalization of the path.
-
normalizePath
Normalizes a path by unescaping all safe, percent encoded characters. -
lenientDecode
Percent-decodes a US-ASCII string into a Unicode string. The specified encoding is used to determine what characters are represented by any consecutive sequences of the form "%XX". This is the lenient kind of decoding that will simply ignore and copy as-is any "%XX" sequence that is invalid (for example, "%HH").- Parameters:
string
- a percent-encoded US-ASCII stringencoding
- a character encodingdecodePlus
- boolean to indicate whether to decode '+' as ' '- Returns:
- a Unicode string
-