Package org.javalite.activeweb
Interface RequestAccess
- All Known Implementing Classes:
AbstractLesscController,AbstractLoggingFilter,AbstractSASSController,AppController,AppControllerFilter,ConfirmationTag,CSRFFilter,CSRFTokenTag,DBConnectionFilter,DebugTag,FormTag,FreeMarkerTag,HeadersLogFilter,HttpSupport,HttpSupportFilter,LinkToTag,MessageTag,RequestParamsLogFilter,RequestPropertiesLogFilter,SelectTag,SimpleController,StatisticsFilter,YieldTag
public interface RequestAccess
Provides access to request values.
- Author:
- igor, on 6/16/14.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault AppContextReturns instance ofAppContext.default Stringcontext()Provides a context of the request - usually an app name (as seen on URL of request).default CookieReturns a cookie by name, null if not found.cookies()Returns collection of all cookies browser sent.default StringcookieValue(String name)Convenience method, returns cookie value.default booleanTests if a request parameter exists.default Stringformat()Returns a format part of the URI, or null if URI does not have a format part.default StringgetId()Returns value of ID if one is present on a URL.default LocaleSame aslocale().default StringThis method returns a host name of a web server if this container is fronted by one, such that it sets a headerX-Forwarded-Hoston the request and forwards it to the Java container.default intThis method returns a port of a web server if this Java container is fronted by one, such that it sets a headerX-Forwarded-Porton the request and forwards it to the Java container.default Stringdefault StringThis method returns a protocol of a request to web server if this container is fronted by one, such that it sets a headerX-Forwarded-Protoon the request and forwards it to the Java container.default RoutegetRoute()Returns instance ofRouteto be used for potential conditional logic inside controller filters.default StringReturns a request header by name.headers()Returns all headers from a request keyed by header name.default Stringhost()Returns local host name on which request was received.default StringReturns local IP address on which request was received.default StringReturns IP address that the web server forwarded request for.default booleanisDelete()True if this request uses HTTP DELETE method, false otherwise.default booleanisGet()True if this request uses HTTP GET method, false otherwise.default booleanisHead()True if this request uses HTTP HEAD method, false otherwise.default booleandefault booleandefault booleanisPost()True if this request uses HTTP POST method, false otherwise.default booleanisPut()True if this request uses HTTP PUT method, false otherwise.default booleanisXhr()Returns true if this request is Ajax.default Localelocale()Returns locale of request.default Stringmethod()Returns an HTTP method from the request.default StringReturns value of routing user segment, or route wild card value, or request parameter.default StringConvenience method to get a parameter value in casemultipart/form-datarequest was used.params()Returns an instance ofjava.util.Mapcontaining parameter names as keys and parameter values as map values.Returns multiple request values for a name.Convenience method to get parameter values in casemultipart/form-datarequest was used.Returns a map where keys are names of all parameters, while values are the first value for each parameter, even if such parameter has more than one value submitted.Convenience method to get parameters in casemultipart/form-datarequest was used.default Stringpath()Returns a path of the request.default intport()Returns port on which the of the server received current request.default Stringprotocol()Returns protocol of request, for example: HTTP/1.1.default StringReturns query string of the request.default StringIP address of the requesting client.default StringHost name of the requesting client.default booleanrequestHas(String name)Synonym ofexists(String).default Stringdefault Objectdefault voidSets an object on a current session.default Stringuri()Returns URI, or a full path of request.default Stringurl()Returns a full URL of the request, all except a query string.default StringHelper method, returns user-agent header of the request.default booleanxhr()Synonym forisXhr().
-
Field Details
-
LOGGER
static final org.slf4j.Logger LOGGER
-
-
Method Details
-
isMultipartContent
default boolean isMultipartContent() -
param
Returns value of routing user segment, or route wild card value, or request parameter. If this name represents multiple values, this call will result inIllegalArgumentException.- Parameters:
name- name of parameter.- Returns:
- value of routing user segment, or route wild card value, or request parameter.
-
param
Convenience method to get a parameter value in casemultipart/form-datarequest was used. Returns a value of one named parameter from request. Will only return form fields, and not files.- Parameters:
name- name of parameter.formItems- form items retrieved frommultipart/form-datarequest.- Returns:
- value of request parameter from
multipart/form-datarequest or null if not found.
-
getId
Returns value of ID if one is present on a URL. Id is usually a part of a URI, such as:/controller/action/id. This depends on a type of a URI, and whether controller is RESTful or not.- Returns:
- ID value from URI is one exists, null if not.
-
format
Returns a format part of the URI, or null if URI does not have a format part. A format part is defined as part of URI that is trailing after a last dot, as in:/books.xml, here "xml" is a format.- Returns:
- format part of the URI, or nul if URI does not have it.
-
appContext
Returns instance ofAppContext.- Returns:
- instance of
AppContext.
-
isXhr
default boolean isXhr()Returns true if this request is Ajax.- Returns:
- true if this request is Ajax.
- See Also:
- List_of_HTTP_header_fields
-
userAgent
Helper method, returns user-agent header of the request.- Returns:
- user-agent header of the request.
-
xhr
default boolean xhr()Synonym forisXhr(). -
getRoute
Returns instance ofRouteto be used for potential conditional logic inside controller filters.- Returns:
- instance of
Route
-
exists
Tests if a request parameter exists. Disregards the value completely - this can be empty string, but as long as parameter does exist, this method returns true.- Parameters:
name- name of request parameter to test.- Returns:
- true if parameter exists, false if not.
-
requestHas
Synonym ofexists(String).- Parameters:
name- name of request parameter to test.- Returns:
- true if parameter exists, false if not.
-
host
Returns local host name on which request was received.- Returns:
- local host name on which request was received.
-
ipAddress
Returns local IP address on which request was received.- Returns:
- local IP address on which request was received.
-
getRequestProtocol
This method returns a protocol of a request to web server if this container is fronted by one, such that it sets a headerX-Forwarded-Protoon the request and forwards it to the Java container. If such header is not present, than theprotocol()method is used.- Returns:
- protocol of web server request if
X-Forwarded-Protoheader is found, otherwise current protocol.
-
getRequestPort
default int getRequestPort()This method returns a port of a web server if this Java container is fronted by one, such that it sets a headerX-Forwarded-Porton the request and forwards it to the Java container. If such header is not present, than theport()method is used.- Returns:
- port of web server request if
X-Forwarded-Portheader is found, otherwise port of the Java container.
-
port
default int port()Returns port on which the of the server received current request.- Returns:
- port on which the of the server received current request.
-
protocol
Returns protocol of request, for example: HTTP/1.1.- Returns:
- protocol of request
-
getRequestHost
This method returns a host name of a web server if this container is fronted by one, such that it sets a headerX-Forwarded-Hoston the request and forwards it to the Java container. If such header is not present, than thehost()method is used.- Returns:
- host name of web server if
X-Forwarded-Hostheader is found, otherwise local host name.
-
ipForwardedFor
Returns IP address that the web server forwarded request for.- Returns:
- IP address that the web server forwarded request for.
-
params
Returns multiple request values for a name.- Parameters:
name- name of multiple values from request.- Returns:
- multiple request values for a name.
-
params
Convenience method to get parameter values in casemultipart/form-datarequest was used. Returns multiple request values for a name.- Parameters:
name- name of multiple values from request.formItems- form items retrieved frommultipart/form-datarequest.- Returns:
- multiple request values for a name. Will ignore files, and only return form fields.
-
params1st
Returns a map where keys are names of all parameters, while values are the first value for each parameter, even if such parameter has more than one value submitted.- Returns:
- a map where keys are names of all parameters, while values are first value for each parameter, even if such parameter has more than one value submitted.
-
params1st
Convenience method to get parameters in casemultipart/form-datarequest was used. Returns a map where keys are names of all parameters, while values are the first value for each parameter, even if such parameter has more than one value submitted.- Parameters:
formItems- form items retrieved frommultipart/form-datarequest.- Returns:
- a map where keys are names of all parameters, while values are first value for each parameter, even if such parameter has more than one value submitted.
-
params
Returns an instance ofjava.util.Mapcontaining parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.- Returns:
- an instance
java.util.Mapcontaining parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.
-
locale
Returns locale of request.- Returns:
- locale of request.
-
getLocale
Same aslocale().- Returns:
- locale of request.
-
cookies
Returns collection of all cookies browser sent.- Returns:
- collection of all cookies browser sent.
-
cookie
Returns a cookie by name, null if not found.- Parameters:
name- name of a cookie.- Returns:
- a cookie by name, null if not found.
-
cookieValue
Convenience method, returns cookie value.- Parameters:
name- name of cookie.- Returns:
- cookie value.
-
path
Returns a path of the request. It does not include protocol, host, port or context. Just a path. Example:/controller/action/id- Returns:
- a path of the request.
-
url
Returns a full URL of the request, all except a query string.- Returns:
- a full URL of the request, all except a query string.
-
queryString
Returns query string of the request.- Returns:
- query string of the request.
-
method
Returns an HTTP method from the request.- Returns:
- an HTTP method from the request.
-
isGet
default boolean isGet()True if this request uses HTTP GET method, false otherwise.- Returns:
- True if this request uses HTTP GET method, false otherwise.
-
isPost
default boolean isPost()True if this request uses HTTP POST method, false otherwise.- Returns:
- True if this request uses HTTP POST method, false otherwise.
-
isPut
default boolean isPut()True if this request uses HTTP PUT method, false otherwise.- Returns:
- True if this request uses HTTP PUT method, false otherwise.
-
isDelete
default boolean isDelete()True if this request uses HTTP DELETE method, false otherwise.- Returns:
- True if this request uses HTTP DELETE method, false otherwise.
-
isMethod
-
isHead
default boolean isHead()True if this request uses HTTP HEAD method, false otherwise.- Returns:
- True if this request uses HTTP HEAD method, false otherwise.
-
context
Provides a context of the request - usually an app name (as seen on URL of request). Example:/mywebapp- Returns:
- a context of the request - usually an app name (as seen on URL of request).
-
uri
Returns URI, or a full path of request. This does not include protocol, host or port. Just context and path. Examlpe:/mywebapp/controller/action/id- Returns:
- URI, or a full path of request.
-
remoteHost
Host name of the requesting client.- Returns:
- host name of the requesting client.
-
remoteAddress
IP address of the requesting client.- Returns:
- IP address of the requesting client.
-
header
Returns a request header by name.- Parameters:
name- name of header- Returns:
- header value.
-
headers
Returns all headers from a request keyed by header name.- Returns:
- all headers from a request keyed by header name.
-
session
- Parameters:
name- name of an object in session- Returns:
- object in session, or null.
-
session
Sets an object on a current session.- Parameters:
name- name of objectvalue- value of object
-
getRequestProperties
-
servletPath
-