Package org.pac4j.core.context
Interface WebContext
public interface WebContext
This interface represents the web context to use HTTP request and response.
- Since:
- 1.4.0
- Author:
- Jerome Leleu
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddResponseCookie(Cookie cookie) Adds cookies to the responseReturn the full URL (with query string) the client used to request the server.getPath()Get the "servlet path" (in a JEE style).default StringGet the protocol version.Return the remote address.getRequestAttribute(String name) Return a request attribute.default StringGets content body of the original request.Retrieves request cookies.getRequestHeader(String name) Return a request header.Return the request method.getRequestParameter(String name) Return a request parameter.Return all request parameters.default StringReturn the full URL (without the query string) the client used to request the server.getResponseHeader(String name) Get a header from the response.Return the scheme.Return the server name.intReturn the server port.booleanisSecure()Return whether the request is secure.voidsetRequestAttribute(String name, Object value) Save a request attribute.voidsetResponseContentType(String content) Sets the response content type.voidsetResponseHeader(String name, String value) Add a header to the response.
-
Method Details
-
getRequestParameter
Return a request parameter.- Parameters:
name- name of the parameter- Returns:
- the request parameter
-
getRequestParameters
Return all request parameters.- Returns:
- all request parameters
-
getRequestAttribute
Return a request attribute.- Parameters:
name- the name of the attribute- Returns:
- the attribute
-
setRequestAttribute
Save a request attribute.- Parameters:
name- the name of the attributevalue- the attribute
-
getRequestHeader
Return a request header.- Parameters:
name- name of the header- Returns:
- the request header
-
getRequestMethod
String getRequestMethod()Return the request method.- Returns:
- the request method
-
getRemoteAddr
String getRemoteAddr()Return the remote address.- Returns:
- the remote address.
-
setResponseHeader
Add a header to the response.- Parameters:
name- name of the headervalue- value of the header
-
getResponseHeader
Get a header from the response.- Parameters:
name- name of the header- Returns:
- the value of the header
-
setResponseContentType
Sets the response content type.- Parameters:
content- the content type
-
getServerName
String getServerName()Return the server name.- Returns:
- the server name
-
getServerPort
int getServerPort()Return the server port.- Returns:
- the server port
-
getScheme
String getScheme()Return the scheme.- Returns:
- the scheme
-
isSecure
boolean isSecure()Return whether the request is secure.- Returns:
- whether the request is secure
-
getFullRequestURL
String getFullRequestURL()Return the full URL (with query string) the client used to request the server.- Returns:
- the URL
- Since:
- 1.5.0
-
getRequestURL
Return the full URL (without the query string) the client used to request the server.- Returns:
- the URL
- Since:
- 5.1.2
-
getRequestCookies
Collection<Cookie> getRequestCookies()Retrieves request cookies.- Returns:
- the request cookies
- Since:
- 1.8.0
-
addResponseCookie
Adds cookies to the response- Parameters:
cookie- a cookie to add to the response- Since:
- 1.8.0
-
getPath
String getPath()Get the "servlet path" (in a JEE style).- Returns:
- the "servlet path"
- Since:
- 1.8.1
-
getRequestContent
Gets content body of the original request.- Returns:
- the request content
- Since:
- 1.9.2
-
getProtocol
Get the protocol version.- Returns:
- the protocol version
-