public interface IRequestWebScopeWithoutResponse extends com.helger.scope.IRequestScope, IWebScope
| Modifier and Type | Method and Description |
|---|---|
default boolean |
areCookiesEnabled()
Check if this request uses a Cookie based session handling (meaning cookies
are enabled) or whether the session ID needs to be appended to a URL.
|
default com.helger.commons.url.ISimpleURL |
encodeRedirectURL(com.helger.commons.url.ISimpleURL aURL)
Encodes the specified URL for use in the
sendRedirect method
or, if encoding is not needed, returns the URL unchanged. |
String |
encodeRedirectURL(String sURL)
Encodes the specified URL for use in the
sendRedirect method
or, if encoding is not needed, returns the URL unchanged. |
default com.helger.commons.url.ISimpleURL |
encodeURL(com.helger.commons.url.ISimpleURL aURL)
Encodes the specified URL by including the session ID in it, 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.
|
default String |
getAuthType()
Returns the name of the authentication scheme used to protect the servlet.
|
default com.helger.useragent.browser.BrowserInfo |
getBrowserInfo() |
default String |
getCharacterEncoding()
Returns the name of the character encoding used in the body of this
request.
|
default Charset |
getCharset() |
default long |
getContentLength()
Returns the length, in bytes, of the request body and made available by the
input stream, or -1 if the length is not known.
|
default String |
getContentType()
Returns the MIME type of the body of the request, or
null if
the type is not known. |
String |
getContextAndServletPath() |
String |
getContextPath() |
default javax.servlet.http.Cookie[] |
getCookies()
Returns an array containing all of the
Cookie objects the
client sent with this request. |
String |
getFullContextAndServletPath() |
default String |
getFullContextPath() |
default String |
getFullServerPath() |
default com.helger.commons.http.EHttpMethod |
getHttpMethod() |
default com.helger.http.EHttpVersion |
getHttpVersion() |
default String |
getLocalAddr()
Returns the Internet Protocol (IP) address of the interface on which the
request was received.
|
default String |
getLocalName()
Returns the host name of the Internet Protocol (IP) interface on which the
request was received.
|
default int |
getLocalPort()
Returns the Internet Protocol (IP) port number of the interface on which
the request was received.
|
default String |
getMethod()
Returns the name of the HTTP method with which this request was made, for
example, GET, POST, or PUT.
|
default String |
getPathInfo()
Returns any extra path information associated with the URL the client sent
when it made this request.
|
default String |
getPathTranslated()
Returns any extra path information after the servlet name but before the
query string, and translates it to a real path.
|
default String |
getPathWithinServlet()
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.
|
default String |
getPathWithinServletContext()
Return the URI of the request within the servlet context.
|
default String |
getProtocol()
Returns the name and version of the protocol the request uses in the form
protocol/majorVersion.minorVersion, for example, HTTP/1.1.
|
default String |
getQueryString()
Returns the query string that is contained in the request URL after the
path.
|
default String |
getRemoteAddr()
Returns the Internet Protocol (IP) address of the client or last proxy that
sent the request.
|
default String |
getRemoteHost()
Returns the fully qualified name of the client or the last proxy that sent
the request.
|
default int |
getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy
that sent the request.
|
default String |
getRemoteUser()
Returns the login of the user making this request, if the user has been
authenticated, or
null if the user has not been authenticated. |
javax.servlet.http.HttpServletRequest |
getRequest() |
default String |
getRequestedSessionId()
Returns the session ID specified by the client.
|
com.helger.servlet.request.IRequestParamMap |
getRequestParamMap() |
default String |
getRequestURI()
Returns the part of this request's URL from the protocol name up to the
query string in the first line of the HTTP request.
|
default StringBuilder |
getRequestURL()
Reconstructs the URL the client used to make the request.
|
default String |
getScheme()
Returns the name of the scheme used to make this request, for example,
http, https, or ftp. |
default String |
getServerName()
Returns the host name of the server to which the request was sent.
|
default int |
getServerPort()
Returns the port number to which the request was sent.
|
default String |
getServletPath()
Returns the part of this request's URL that calls the servlet.
|
default javax.servlet.http.HttpSession |
getSession(boolean bCreateIfNotExisting)
Returns the current
HttpSession associated with this request
or, if there is no current session and create is true, returns
a new session. |
default String |
getSessionID(boolean bCreateIfNotExisting) |
default String |
getURL()
Get the full URL (incl. protocol) and parameters of the current request.
|
default com.helger.useragent.IUserAgent |
getUserAgent()
Get the user agent object of this HTTP request.
|
default Principal |
getUserPrincipal()
Returns a
java.security.Principal object containing the name
of the current authenticated user. |
com.helger.commons.http.HttpHeaderMap |
headers() |
default boolean |
isRequestedSessionIdFromCookie()
Checks whether the requested session ID came in as a cookie.
|
default boolean |
isRequestedSessionIdFromURL()
Checks whether the requested session ID came in as part of the request URL.
|
default boolean |
isRequestedSessionIdValid()
Checks whether the requested session ID is still valid.
|
default boolean |
isSecure()
Returns a boolean indicating whether this request was made using a secure
channel, such as HTTPS.
|
default boolean |
isUserInRole(String sRole)
Returns a boolean indicating whether the authenticated user is included in
the specified logical "role".
|
IRequestParamContainer |
params() |
@Nonnull @ReturnsMutableObject com.helger.commons.http.HttpHeaderMap headers()
null.
Alterations to this map are visible everywhere. Clone the object if
you need to modify it.@Nonnull default com.helger.useragent.IUserAgent getUserAgent()
null user agent object.@Nullable default com.helger.useragent.browser.BrowserInfo getBrowserInfo()
null if
no known browser was detected.@Nonnull @ReturnsMutableObject IRequestParamContainer params()
null.@Nonnull com.helger.servlet.request.IRequestParamMap getRequestParamMap()
null.@Nullable default String getSessionID(boolean bCreateIfNotExisting)
getSessionID in interface com.helger.scope.IRequestScope@Nullable default String getCharacterEncoding()
null if the request does not
specify a character encodingString containing the name of the character
encoding, or null if the request does not specify a
character encodingdefault String getContentType()
null if
the type is not known. For HTTP servlets, same as the value of the CGI
variable CONTENT_TYPE.String containing the name of the MIME type of the
request, or null if the type is not knowndefault long getContentLength()
@Nullable default Charset getCharset()
null if
none is present;default String getProtocol()
SERVER_PROTOCOL.String containing the protocol name and version
number@Nullable default com.helger.http.EHttpVersion getHttpVersion()
EHttpVersion of the request.default String getScheme()
http, https, or ftp. Different
schemes have different rules for constructing URLs, as noted in RFC 1738.String containing the name of the scheme used to
make this requestdefault String getServerName()
Host header value, if
any, or the resolved server name, or the server IP address.String containing the name of the serverdefault int getServerPort()
Host header value, if any, or the
server port where the client connection was accepted on.default String getRemoteAddr()
REMOTE_ADDR.String containing the IP address of the client that
sent the requestdefault String getRemoteHost()
REMOTE_HOST.String containing the fully qualified name of the
clientdefault int getRemotePort()
default boolean isSecure()
default String getLocalName()
String containing the host name of the IP on which
the request was received.default String getLocalAddr()
String containing the IP address on which the
request was received.default int getLocalPort()
default String getAuthType()
null is returned.
Same as the value of the CGI variable AUTH_TYPE.
null
if the request was not authenticated.@Nullable default javax.servlet.http.Cookie[] getCookies()
Cookie objects the
client sent with this request. This method returns null if no
cookies were sent.Cookies included with this
request, or null if the request has no cookiesdefault String getMethod()
String specifying the name of the method with which
this request was made@Nullable default com.helger.commons.http.EHttpMethod getHttpMethod()
EHttpMethod matching the getMethod()default String getPathInfo()
This method returns null if there was no extra path
information.
Same as the value of the CGI variable PATH_INFO.
String, decoded by the web container, specifying
extra path information that comes after the servlet path but before
the query string in the request URL; or null if the
URL does not have any extra path informationdefault String getPathTranslated()
If the URL does not have any extra path information, this method returns
null or the servlet container cannot translate the virtual
path to a real path for any reason (such as when the web application is
executed from an archive). The web container does not decode this string.
String specifying the real path, or
null if the URL does not have any extra path
information@Nonnull String getContextPath()
/context or an empty string for the root context.
Never with a trailing slash.getFullContextPath()default String getQueryString()
null if the URL does not have a
query string. Same as the value of the CGI variable QUERY_STRING.String containing the query string or
null if the URL contains no query string. The value is
not decoded by the container.default String getRemoteUser()
null if the user has not been authenticated.
Whether the user name is sent with each subsequent request depends on the
browser and type of authentication. Same as the value of the CGI variable
REMOTE_USER.String specifying the login of the user making this
request, or null if the user login is not knowndefault boolean isUserInRole(String sRole)
false.sRole - a String specifying the name of the roleboolean indicating whether the user making this
request belongs to a given role; false if the user has
not been authenticated@Nullable default Principal getUserPrincipal()
java.security.Principal object containing the name
of the current authenticated user. If the user has not been authenticated,
the method returns null.java.security.Principal containing the name of the
user making this request; null if the user has not
been authenticated@Nullable default String getRequestedSessionId()
null.String specifying the session ID, or
null if the request did not specify a session IDisRequestedSessionIdValid()default String getRequestURI()
| First line of HTTP request | Returned Value |
|---|---|
| POST /some/path.html HTTP/1.1 | /some/path.html |
| GET http://foo.bar/a.html HTTP/1.0 | /a.html |
| HEAD /xyz?a=b HTTP/1.1 | /xyz |
String containing the part of the URL from the
protocol name up to the query stringdefault StringBuilder getRequestURL()
If this request has been forwarded using
RequestDispatcher.forward(javax.servlet.ServletRequest, javax.servlet.ServletResponse), the server path in the
reconstructed URL must reflect the path used to obtain the
RequestDispatcher, and not the server path specified by the client.
Because this method returns a StringBuffer, not a string, you
can modify the URL easily, for example, to append query parameters.
This method is useful for creating redirect messages and for reporting errors.
StringBuilder object containing the reconstructed
URL@Nonnull default String getServletPath()
This method will return an empty string ("") if the servlet used to process this request was matched using the "/*" pattern.
String containing the name or path of the servlet
being called, as specified in the request URL, decoded, or an empty
string if the servlet used to process the request is matched using
the "/*" pattern.@Nullable default javax.servlet.http.HttpSession getSession(boolean bCreateIfNotExisting)
HttpSession associated with this request
or, if there is no current session and create is true, returns
a new session.
If bCreateIfNotExisting is false and the request
has no valid HttpSession, this method returns
null.
To make sure the session is properly maintained, you must call this method before the response is committed. If the container is using cookies to maintain session integrity and is asked to create a new session when the response is committed, an IllegalStateException is thrown.
bCreateIfNotExisting - true to create a new session for this request if
necessary; false to return null if there's
no current sessionHttpSession associated with this request or
null if bCreateIfNotExisting is
false and the request has no valid sessiondefault boolean isRequestedSessionIdValid()
If the client did not specify any session ID, this method returns
false.
true if this request has an id for a valid session in
the current session context; false otherwisegetRequestedSessionId(),
getSession(boolean)default boolean isRequestedSessionIdFromCookie()
true if the session ID came in as a cookie; otherwise,
falsegetSession(boolean)default boolean isRequestedSessionIdFromURL()
true if the session ID came in as part of a URL;
otherwise, falsegetSession(boolean)@Nonnull default String getFullServerPath()
@Nonnull default String getFullContextPath()
http://localhost:8080/context. Never with a trailing
slash.getContextPath()@Nonnull String getContextAndServletPath()
/context/config.jsp or /context/action/@Nonnull String getFullContextAndServletPath()
http://localhost:8080/context/config.jsp or
http://localhost:8080/context/action/@Nonnull @Nonempty default String getURL()
http://hostname.com:81/context/servlet/path/a/b?c=123&d=789@Nonnull String encodeURL(@Nonnull String sURL)
For 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.
sURL - the url to be encoded. May not be null.@Nonnull default com.helger.commons.url.ISimpleURL encodeURL(@Nonnull com.helger.commons.url.ISimpleURL aURL)
For 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.
aURL - the url to be encoded. May not be null.null.@Nonnull String encodeRedirectURL(@Nonnull String sURL)
sendRedirect 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.
sURL - the url to be encoded.encodeURL(String)@Nonnull default com.helger.commons.url.ISimpleURL encodeRedirectURL(@Nonnull com.helger.commons.url.ISimpleURL aURL)
sendRedirect 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.
aURL - the url to be encoded. May not be null.null.encodeURL(String)default boolean areCookiesEnabled()
true if the session ID is passed via cookies.@Nonnull default String getPathWithinServletContext()
null. By
default "/" is returned is an empty request URI is determined.@Nonnull default String getPathWithinServlet()
@Nonnull javax.servlet.http.HttpServletRequest getRequest()
null
.Copyright © 2014–2019 Philip Helger. All rights reserved.