Request
Overview
Module
- package:
org.eclipse.dirigible.sdk.http - source: http/Request.java
Inspects the inbound HTTP request bound to the calling thread — method, headers, cookies, query parameters, body. Use this from a @Controller method that needs more than the parameter-binding annotations (e.g. raw header inspection, parameter iteration, streaming the body).
getNative() hands back the underlying HttpServletRequest when you need to call into Servlet APIs that aren't exposed through the static helpers; the helpers themselves are sufficient for the vast majority of use cases and keep call sites free of Servlet imports.
Key Features:
- Thread-bound: All methods operate on the request bound to the current thread; there is no instance to pass around.
- Servlet Escape Hatch:
getNative()exposes the underlyingHttpServletRequestwhen you need to drop down to the Servlet API. - JSON-shaped Collections: Aggregate helpers (
getHeaderNames,getCookies,getParameters,getAttributeNames,getParameterValues) return JSON-encoded strings for easy serialisation.
Example Usage:
import org.eclipse.dirigible.sdk.http.Request;
if (Request.isValid()) {
String method = Request.getMethod();
String auth = Request.getHeader("Authorization");
String body = Request.getText();
// ...
}Methods
getNative()
Returns the underlying Servlet request.
javapublic static HttpServletRequest getNative();Returns
- Type:
jakarta.servlet.http.HttpServletRequest- Description: The Servlet request bound to the current thread.
isValid()
Returns whether an HTTP request is bound to the current thread.
javapublic static boolean isValid();Returns
- Type:
boolean- Description:
truewhen a request is in scope.
getMethod()
Returns the HTTP method (GET, POST, …).
javapublic static String getMethod();Returns
- Type:
String
getRemoteUser()
Returns the authenticated remote user.
javapublic static String getRemoteUser();Returns
- Type:
String
getPathInfo()
Returns the extra path information beyond the servlet path.
javapublic static String getPathInfo();Returns
- Type:
String
getHeader()
Returns the value of the named request header.
javapublic static String getHeader(String name);
Parameter Type Description nameStringHeader name. Returns
- Type:
String
getHeaderNames()
Returns the names of all request headers.
javapublic static String getHeaderNames();Returns
- Type:
String- Description: A JSON-encoded list of header names.
getHeaders()
Returns all values for the named header.
javapublic static String getHeaders(String name);
Parameter Type Description nameStringHeader name. Returns
- Type:
String- Description: A JSON-encoded list of header values.
getCookies()
Returns all cookies sent with the request.
javapublic static String getCookies();Returns
- Type:
String- Description: A JSON-encoded list of cookies.
getAttribute()
Returns the value of the named request attribute.
javapublic static String getAttribute(String name);
Parameter Type Description nameStringAttribute name. Returns
- Type:
String
setAttribute()
Sets a request attribute.
javapublic static void setAttribute(String name, String value);
Parameter Type Description nameStringAttribute name. valueStringAttribute value.
removeAttribute()
Removes the named request attribute.
javapublic static void removeAttribute(String name);
Parameter Type Description nameStringAttribute name.
getAttributeNames()
Returns the names of all request attributes.
javapublic static String getAttributeNames();Returns
- Type:
String- Description: A JSON-encoded list of attribute names.
isUserInRole()
Returns whether the authenticated user is in the given role.
javapublic static boolean isUserInRole(String role);
Parameter Type Description roleStringRole name. Returns
- Type:
boolean
getAuthType()
Returns the authentication scheme used (BASIC, FORM, …).
javapublic static String getAuthType();Returns
- Type:
String
getCharacterEncoding()
Returns the character encoding of the request body.
javapublic static String getCharacterEncoding();Returns
- Type:
String
getContentLength()
Returns the request body length in bytes.
javapublic static int getContentLength();Returns
- Type:
int
getContentType()
Returns the request Content-Type header.
javapublic static String getContentType();Returns
- Type:
String
getBytes()
Reads the entire request body as a Base64-encoded byte string.
javapublic static String getBytes() throws IOException;Returns
- Type:
String
getText()
Reads the entire request body as text.
javapublic static String getText() throws IOException;Returns
- Type:
String
getInputStream()
Returns the raw request body as a Servlet input stream — use for streaming uploads.
javapublic static ServletInputStream getInputStream() throws IOException;Returns
- Type:
jakarta.servlet.ServletInputStream
getParameter()
Returns the value of the named request parameter (form field or query parameter).
javapublic static String getParameter(String name);
Parameter Type Description nameStringParameter name. Returns
- Type:
String
getParameters()
Returns all request parameters.
javapublic static String getParameters();Returns
- Type:
String- Description: A JSON-encoded parameter map.
getParameterNames()
Returns the names of all request parameters.
javapublic static String getParameterNames();Returns
- Type:
String- Description: A JSON-encoded list of parameter names.
getParameterValues()
Returns all values for the named request parameter.
javapublic static String getParameterValues(String name);
Parameter Type Description nameStringParameter name. Returns
- Type:
String- Description: A JSON-encoded list of values.
getResourcePath()
Returns the resource path within the service.
javapublic static String getResourcePath();Returns
- Type:
String
getProtocol()
Returns the request protocol (HTTP/1.1, HTTP/2).
javapublic static String getProtocol();Returns
- Type:
String
getScheme()
Returns the URL scheme (http, https).
javapublic static String getScheme();Returns
- Type:
String
getContextPath()
Returns the servlet context path.
javapublic static String getContextPath();Returns
- Type:
String
getServerName()
Returns the host name of the server that received the request.
javapublic static String getServerName();Returns
- Type:
String
getServerPort()
Returns the port number on which the request was received.
javapublic static int getServerPort();Returns
- Type:
int
getQueryString()
Returns the query string portion of the request URL.
javapublic static String getQueryString();Returns
- Type:
String
getRemoteAddress()
Returns the IP address of the client.
javapublic static String getRemoteAddress();Returns
- Type:
String
getRemoteHost()
Returns the host name of the client.
javapublic static String getRemoteHost();Returns
- Type:
String
getLocale()
Returns the preferred locale of the client.
javapublic static String getLocale();Returns
- Type:
String
getRequestURI()
Returns the part of the request URL from the protocol up to the query string.
javapublic static String getRequestURI();Returns
- Type:
String
isSecure()
Returns whether the request came over a secure channel (HTTPS).
javapublic static boolean isSecure();Returns
- Type:
boolean
getRequestURL()
Returns the full URL the client used to make the request.
javapublic static String getRequestURL();Returns
- Type:
String
getServicePath()
Returns the path within the Dirigible service registry that handles this request.
javapublic static String getServicePath();Returns
- Type:
String