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 body

document.writeln is the same, with a trailing newline.

See also

  • 📕 response - The HttpServletResponse object — set the content type, headers, cookies and redirects in a JSSP.
  • 📕 setContentType - Set the HTTP Content-Type header of a JSSP response.