Examples
request is the incoming HttpServletRequest exposed to every JSSP page and web app. Use it to read the query string, the HTTP body, headers, and the client IP — the inputs of a dynamic page or API.
var param1 = request.getParameter("param1"); // URL query parameter
var body = request.getBodyAsString(); // raw HTTP body
var userAgent = request.getHeader("User-Agent"); // request header
var clientIp = request.getRemoteAddr(); // client or last-proxy IP
var httpMethod = request.method; // "GET", "POST"...Methods
| Method | Returns |
|---|---|
getParameter(key) |
Value of a query parameter |
getUTF8Parameter(key) |
Value of a parameter, decoded as UTF-8 |
getBodyAsString() |
The request body as a string |
getHeader(key) |
Value of a request header |
getRemoteAddr() |
IP of the client or last proxy |
forward(url) |
Server-side redirect to another page (no client round-trip) |
Properties
| Property | Returns |
|---|---|
method |
HTTP method (GET, POST, HEAD…) |
parameters |
The query parameters |
cookies |
The request cookies |
requestURI / queryString
|
URI and query-string parts of the URL |
scheme / serverName / serverPort / serverURL
|
Protocol and server info |
servletPath / contextPath / pathInfo
|
Path sections of the URL |
See a full request walkthrough in the JSSP tutorial.
See also
-
📕 response- TheHttpServletResponseobject — set the content type, headers, cookies and redirects in a JSSP. -
📕 setContentType- Set the HTTPContent-Typeheader of a JSSP response. -
📕 write- Append a string to the JSSP response body — the server-side equivalent of print.