@NotThreadSafe public final class ServletContextPathHolder extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
clearContextPath()
Clears both servlet context and custom context path.
|
static String |
getContextPath()
Returns the context path of the web application.
|
static String |
getCustomContextPath() |
static String |
getServletContextPath() |
static boolean |
hasCustomContextPath() |
static boolean |
hasServletContextPath() |
static boolean |
isSilentMode() |
static void |
setCustomContextPath(String sCustomContextPath)
Manually change the context path to be used.
|
static void |
setServletContextPath(String sServletContextPath) |
static boolean |
setSilentMode(boolean bSilentMode) |
public static boolean setSilentMode(boolean bSilentMode)
public static boolean isSilentMode()
public static boolean hasServletContextPath()
true if a servlet context path was set.setServletContextPath(String)@Nullable public static String getServletContextPath()
null.setServletContextPath(String),
getContextPath()public static void setCustomContextPath(@Nonnull String sCustomContextPath)
ServletContext or from the underlying request. This method is
only needed, if a web application is proxied by e.g. an Apache httpd and the
context path between httpd and Java web application server is different!sCustomContextPath - The context path of the web application, or "" for the default (root)
context. May not be null.public static boolean hasCustomContextPath()
true if a custom context path was set.setCustomContextPath(String)@Nullable public static String getCustomContextPath()
null.setCustomContextPath(String),
getContextPath()@Nonnull public static String getContextPath()
The context path is the portion of the request URI that is used to select the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "".
It is possible that a servlet container may match a context by more than one context path. In such cases the context path will return the actual context path used by the request and it may differ from the path returned by this method. The context path returned by this method should be considered as the prime or preferred context path of the application.
public static void clearContextPath()
Copyright © 2016–2019 Philip Helger. All rights reserved.