public class RequestWebScope extends com.helger.scope.AbstractScope implements IRequestWebScope
| Modifier and Type | Class and Description |
|---|---|
static interface |
RequestWebScope.IParamValueCleanser
The param value cleanser interface to be used globally.
|
static class |
RequestWebScope.ParamContainer
Special implementation if
IRequestParamContainer based on
AttributeContainerAny. |
| Modifier and Type | Field and Description |
|---|---|
protected javax.servlet.http.HttpServletRequest |
m_aHttpRequest |
protected javax.servlet.http.HttpServletResponse |
m_aHttpResponse |
| Constructor and Description |
|---|
RequestWebScope(javax.servlet.http.HttpServletRequest aHttpRequest,
javax.servlet.http.HttpServletResponse aHttpResponse) |
| Modifier and Type | Method and Description |
|---|---|
protected com.helger.commons.state.EChange |
addSpecialRequestParams()
Callback method to add special parameters.
|
String |
encodeRedirectURL(String sURL)
Encodes the specified URL for use in the
sendRedirect method
or, if encoding is not needed, returns the URL unchanged. |
String |
encodeURL(String sURL)
Encodes the specified URL by including the session ID in it, or, if
encoding is not needed, returns the URL unchanged.
|
boolean |
equals(Object o) |
String |
getContextAndServletPath() |
String |
getContextPath() |
String |
getFullContextAndServletPath() |
static RequestWebScope.IParamValueCleanser |
getParamValueCleanser() |
javax.servlet.http.HttpServletRequest |
getRequest() |
com.helger.servlet.request.IRequestParamMap |
getRequestParamMap() |
javax.servlet.http.HttpServletResponse |
getResponse() |
static String |
getWithoutForbiddenChars(String s)
Remove all chars from the input that cannot be serialized as XML.
|
static String |
getWithoutForbiddenCharsAndNormalized(String s)
First normalize the input according to Unicode rules, so that "O 0xcc 0x88"
(O with COMBINING DIAERESIS) becomes "Ö" (Capital O with umlaut).
|
int |
hashCode() |
com.helger.commons.http.HttpHeaderMap |
headers() |
void |
initScope() |
static boolean |
isFileBasedRequest(String sServletPath)
This is a heuristic method to determine whether a request is for a file (e.g.
|
static boolean |
isForbiddenParamValueChar(char c)
Check if the provided char is forbidden in a request value or not.
|
IRequestParamContainer |
params() |
protected void |
postDestroy() |
static void |
setParamValueCleanser(RequestWebScope.IParamValueCleanser aParamValueCleanser)
Set the param value cleanser function that is applied on all parameter
values.
|
String |
toString() |
attrs, destroyScope, getID, isDestroyed, isInDestruction, isInPreDestruction, isValid, preDestroy, runAtomic, runAtomicclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetOutputStreamareCookiesEnabled, encodeRedirectURL, encodeURL, getAuthType, getBrowserInfo, getCharacterEncoding, getCharset, getContentLength, getContentType, getCookies, getFullContextPath, getFullServerPath, getHttpMethod, getHttpVersion, getLocalAddr, getLocalName, getLocalPort, getMethod, getPathInfo, getPathTranslated, getPathWithinServlet, getPathWithinServletContext, getProtocol, getQueryString, getRemoteAddr, getRemoteHost, getRemotePort, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getScheme, getServerName, getServerPort, getServletPath, getSession, getSessionID, getURL, getUserAgent, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isSecure, isUserInRoleprotected final transient javax.servlet.http.HttpServletRequest m_aHttpRequest
protected final transient javax.servlet.http.HttpServletResponse m_aHttpResponse
@Nullable public static RequestWebScope.IParamValueCleanser getParamValueCleanser()
null. By
default getWithoutForbiddenCharsAndNormalized(String) is
invoked.setParamValueCleanser(IParamValueCleanser)public static void setParamValueCleanser(@Nullable RequestWebScope.IParamValueCleanser aParamValueCleanser)
getWithoutForbiddenCharsAndNormalized(String) is invoked.aParamValueCleanser - The function to be applied. May be null. The function
itself must be able to handle null values.getParamValueCleanser()@OverrideOnDemand @Nonnull protected com.helger.commons.state.EChange addSpecialRequestParams()
EChange.CHANGED if some attributes were added,
false if not. If special attributes were added, existing
attributes are kept and will not be overwritten with HTTP servlet
request parameters!public static boolean isForbiddenParamValueChar(char c)
c - Char to checktrue if it is forbidden, false if not.getWithoutForbiddenChars(String)@Nullable public static String getWithoutForbiddenChars(@Nullable String s)
s - The source value. May be null.null if the source value is null.isForbiddenParamValueChar(char)@Nullable public static String getWithoutForbiddenCharsAndNormalized(@Nullable String s)
s - Source string. May be null.null if the source string is null.Normalizer.normalize(CharSequence, java.text.Normalizer.Form),
getWithoutForbiddenChars(String)public final void initScope()
initScope in interface com.helger.scope.IScopeprotected void postDestroy()
postDestroy in class com.helger.scope.AbstractScope@Nonnull public final com.helger.commons.http.HttpHeaderMap headers()
headers in interface IRequestWebScopeWithoutResponsenull.
Alterations to this map are visible everywhere. Clone the object if
you need to modify it.@Nonnull @ReturnsMutableObject public final IRequestParamContainer params()
params in interface IRequestWebScopeWithoutResponsenull.@Nonnull public final com.helger.servlet.request.IRequestParamMap getRequestParamMap()
getRequestParamMap in interface IRequestWebScopeWithoutResponsenull.public static boolean isFileBasedRequest(@Nonnull String sServletPath)
true if the last dot
is after the last slashsServletPath - The non-null servlet path to checktrue if it is assumed that the request is file based,
false if it can be assumed to be a regular servlet.@Nonnull public String getContextPath()
getContextPath in interface IRequestWebScopeWithoutResponse/context or an empty string for the root context. Never
with a trailing slash.IRequestWebScopeWithoutResponse.getFullContextPath()@Nonnull public String getContextAndServletPath()
getContextAndServletPath in interface IRequestWebScopeWithoutResponse/context/config.jsp or /context/action/@Nonnull public String getFullContextAndServletPath()
getFullContextAndServletPath in interface IRequestWebScopeWithoutResponsehttp://localhost:8080/context/config.jsp or
http://localhost:8080/context/action/@Nonnull public final javax.servlet.http.HttpServletRequest getRequest()
getRequest in interface IRequestWebScopeWithoutResponsenull
.@Nonnull public final javax.servlet.http.HttpServletResponse getResponse()
getResponse in interface IRequestWebScope@Nonnull public String encodeURL(@Nonnull String sURL)
IRequestWebScopeWithoutResponseFor robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.
encodeURL in interface IRequestWebScopeWithoutResponsesURL - the url to be encoded. May not be null.@Nonnull public String encodeRedirectURL(@Nonnull String sURL)
IRequestWebScopeWithoutResponsesendRedirect method
or, if encoding is not needed, returns the URL unchanged. The
implementation of this method includes the logic to determine whether the
session ID needs to be encoded in the URL. Because the rules for making
this determination can differ from those used to decide whether to encode a
normal link, this method is separated from the encodeURL
method.
All URLs sent to the HttpServletResponse.sendRedirect method
should be run through this method. Otherwise, URL rewriting cannot be used
with browsers which do not support cookies.
encodeRedirectURL in interface IRequestWebScopeWithoutResponsesURL - the url to be encoded.IRequestWebScopeWithoutResponse.encodeURL(String)public boolean equals(Object o)
equals in class com.helger.scope.AbstractScopepublic int hashCode()
hashCode in class com.helger.scope.AbstractScopepublic String toString()
toString in class com.helger.scope.AbstractScopeCopyright © 2014–2019 Philip Helger. All rights reserved.