Parameters
content |
string | String appended to the response body. |
Examples
document.write appends a string to the response body. It is how a JSSP emits its output outside the static <% %> template — typically the serialized payload of an API.
For JSON, pair it with JSON.stringify and an application/json 📕 setContentType.
var payload = { status: "OK", count: 1 };
document.write(JSON.stringify(payload)); // write the response bodydocument.writeln is the same, with a trailing newline.
See also
-
📕 response- TheHttpServletResponseobject — set the content type, headers, cookies and redirects in a JSSP. -
📕 setContentType- Set the HTTPContent-Typeheader of a JSSP response.