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
-
Method Summary
Modifier and TypeMethodDescriptiondefault AppContext
Returns instance ofAppContext
.default String
context()
Provides a context of the request - usually an app name (as seen on URL of request).default Cookie
Returns a cookie by name, null if not found.cookies()
Returns collection of all cookies browser sent.default String
cookieValue(String name)
Convenience method, returns cookie value.default boolean
Tests if a request parameter exists.default String
format()
Returns a format part of the URI, or null if URI does not have a format part.default String
getId()
Returns value of ID if one is present on a URL.default Locale
Same aslocale()
.default String
This method returns a host name of a web server if this container is fronted by one, such that it sets a headerX-Forwarded-Host
on the request and forwards it to the Java container.default int
This method returns a port of a web server if this Java container is fronted by one, such that it sets a headerX-Forwarded-Port
on the request and forwards it to the Java container.default String
default String
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-Proto
on the request and forwards it to the Java container.default Route
getRoute()
Returns instance ofRoute
to be used for potential conditional logic inside controller filters.default String
Returns a request header by name.headers()
Returns all headers from a request keyed by header name.default String
host()
Returns local host name on which request was received.default String
Returns local IP address on which request was received.default String
Returns IP address that the web server forwarded request for.default boolean
isDelete()
True if this request uses HTTP DELETE method, false otherwise.default boolean
isGet()
True if this request uses HTTP GET method, false otherwise.default boolean
isHead()
True if this request uses HTTP HEAD method, false otherwise.default boolean
default boolean
default boolean
isPost()
True if this request uses HTTP POST method, false otherwise.default boolean
isPut()
True if this request uses HTTP PUT method, false otherwise.default boolean
isXhr()
Returns true if this request is Ajax.default Locale
locale()
Returns locale of request.default String
method()
Returns an HTTP method from the request.default String
Returns value of routing user segment, or route wild card value, or request parameter.default String
Convenience method to get a parameter value in casemultipart/form-data
request was used.params()
Returns an instance ofjava.util.Map
containing 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-data
request 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-data
request was used.default String
path()
Returns a path of the request.default int
port()
Returns port on which the of the server received current request.default String
protocol()
Returns protocol of request, for example: HTTP/1.1.default String
Returns query string of the request.default String
IP address of the requesting client.default String
Host name of the requesting client.default boolean
requestHas(String name)
Synonym ofexists(String)
.default String
default Object
default void
Sets an object on a current session.default String
uri()
Returns URI, or a full path of request.default String
url()
Returns a full URL of the request, all except a query string.default String
Helper method, returns user-agent header of the request.default boolean
xhr()
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-data
request 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-data
request.- Returns:
- value of request parameter from
multipart/form-data
request 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 ofRoute
to 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-Proto
on 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-Proto
header 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-Port
on 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-Port
header 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-Host
on 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-Host
header 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-data
request was used. Returns multiple request values for a name.- Parameters:
name
- name of multiple values from request.formItems
- form items retrieved frommultipart/form-data
request.- 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-data
request 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-data
request.- 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.Map
containing 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.Map
containing 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
-