Response (res) - Axiom

The response object provides methods and properties for the response to be sent back to the client. It is global, which means you can access this object from any script. It is instantiated as "res".


Contents

res.cache

Description

res.cache

(Boolean) - True if the response is cacheable. This can be set using res.setCache().

Also See...


res.charset

Description

res.charset

(String) - The current setting of the Charset portion of the Content-Type response header. This can be set using res.setCharset().

Also See...


res.contentType

Description

res.contentType

(String) - The current setting of the Content-Type response header. This can be set using res.setContentType().

Also See...


res.error

Description

res.error

(String) - The current error message for the response, if any. If the request leads to an internal Axiom error, an error message will be set on the response object, which can be obtained by using this property.

Also See...


res.ETag

Description

res.ETag

(String) - The current setting of the ETag response header. This can be set using res.setETag() or res.setHeader().

Also See...


res.lastModified

Description

res.lastModified

(Date) - The last modified date header for this response.

Also See...


res.servletResponse

Description

res.servletResponse

(Object) - The underlying Jetty Response Object.

Also See...


res.status

Description

res.status

(Number) - The HTTP Status Code

Also See...


res.abort()

Description

res.abort()

Aborts the current transaction by throwing an error.

Also See...


res.addDateHeader()

Description

res.addDateHeader(name, date)

Adds a response header with the given name and date-value.

Parameters

  • name (String) - The name of the Header to set
  • date (Date) - The date value to set the header to.

Examples

res.addDateHeader("Date", new Date("10/25/2005"));
res.write("Response with Date Header changed");

This will add a response header that sets the Date to October 25, 2005.

Also See...


res.addHeader()

Description

res.addHeader(name, value)

Adds a response header with the given name and value.

Parameters

  • name (String) - The name of the Header to set
  • value (String) - The string value to set the header to.

Also See...


res.commit()

Description

Commits changes made during the course of the current transaction and starts a new one.

Notes

It is recommended to periodically call res.commit() when looping through and making changes to many Axiom Objects.

Examples

var pages = app.getObjects("Page");
for (var i = 0; pages.length; i++) {
    pages.title = "New Title";
    res.commit();
}

This example will loop through all Axiom Objects of the Page prototype, and change their title property to "New Title". The change will be committed immediately after the title is changed. Without the res.commit() statement, the changes would all be committed at once after loop completes.

Also See...


res.debug()

Description

res.debug(message)

Adds an HTML Formatted debug message to the end of the response.

Parameters'

  • message (String) - The debug message.


res.getCache()

Description

res.getCache()

Returns a Boolean representing whether or not the response is cacheable. This can be set using res.setCache().

Returns

(Boolean) - True if the response is cacheable.

Also See...


res.getCharset()

Description

res.getCharset()

Returns a String representing the current setting of the Charset portion of the Content-Type response header. This can be set using res.setCharset().

Returns

(String) - String representing the current setting of the Charset portion of the Content-Type response header.

Also See...


res.getContentType()

Description

res.getContentType()

Returns a String representing the current setting of the Content-Type response header. This can be set using res.setContentType().

Returns

(String) - String representing the current setting of the Content-Type response header.

Also See...


res.getCookies()

Description

res.getCookies()

Returns an Object that contains the cookies data that are currently set to be sent in the response.

Returns

(Object) - Object that contains the cookies that are currently set to be sent in the response, as name/value pairs.

Also See...


res.getETag()

Description

res.getETag()

Returns a String representing the current setting of the ETag response header. This can be set using res.setETag() or res.setHeader.

Returns

(String) - String representing the current setting of the ETag response header.

Also See...


res.getError()

Description

res.getError()

Get the current error message for the response, if any. If the request leads to an internal Axiom error, an error message will be set on the response object, which can be obtained by using this function.

Returns

(String) - The error message.

Also See...


res.getLastModified()

Description

res.getLastModified()

Returns the last modified date header for this response. Must be set with res.setLastModified().

Returns

(Date) - The current setting of the Last Modified Date header.

Also See...


res.getServletResponse()

Description

res.getServletResponse()

Returns the underlying Jetty Response Object.

Returns

(Object) - The underlying Jetty Response Object.

Also See...


res.getStatus()

Description

res.getStatus()

Returns the HTTP Status Code.

Returns (Number) - The HTTP Status Code.

Also See...


res.redirect()

Description

res.redirect(uri)

Redirects response to the specified URI.

Parameters uri (String) - The URI to redirect to.


res.reset()

Description

res.reset()

Resets the response, clearing everything previously set and written to it.


res.rollback()

Description

res.rollback()

Rollback the current transaction and starts a new one.

Also See...


res.setCache()

Description

res.setCache(cacheable)

Sets headers that make the response cachable or not.

Parameters

  • cacheable (Boolean) - Set this to true to make the response cacheable.

Also See...


res.setCharset()

Description

res.setCharset(charset)

Sets the Charset portion of the Content-Type response header.

Parameters

  • charset (String) - The Character Set to change to.

Also See...


res.setContentType()

Description

res.setContentType(contentType)

Sets the Content-Type response header.

Parameters

  • contentType (String) - The Content-Type to change to.

Also See...


res.setCookie()

Description

res.setCookie(name, value, days, path, domain)

Sets a cookie to be sent down with the response.

Parameters

  • name (String) - The name of the cookie to set.
  • value (String) - The value to set.
  • days (Number, Optional) - The expiration of the cookie.
  • path (String, Optional) - The path of the cookie.
  • domain (String, Optional) - The domain of the cookie.

Also See...


res.setDateHeader()

Description

res.addDateHeader(name, date)

Sets a response header with the given name and date-value.

Parameters

  • name (String) - The name of the Header to set
  • date (Date) - The date value to set the header to.

Examples

res.addDateHeader("Date", new Date("10/25/2005"));
res.write("Response with Date Header changed");

This will set the Date response header to October 25, 2005.

Also See...


res.setETag()

Description

res.setETag(etag)

Sets the ETag response header.

Parameters

  • etag (String) - Value to set the ETag response header to.

Also See...


res.setHeader()

Description

res.addHeader(name, value)

Sets a response header to the given name and value.

Parameters

  • name (String) - The name of the Header to set
  • value (String) - The string value to set the header to.

Also See...


res.setLastModified()

Description

res.setLastModified(date)

Sets the last modified date header for this response.

Parameters

  • date (Date) - The date to set this header to.

Also See...


res.setStatus()

Description

res.setStatus(status)

Sets the HTTP Status Code.

Parameters

  • status (Number) - The HTTP Status Code to set to.

Also See...


res.stop()

Description

res.stop()

Stops the current transaction without throwing an error.

Also See...


res.unsetCookie()

Description

res.unsetCookie(name)

Unsets a cookie.

Parameters

  • name (String) - The name of the cookie to unset.

Also See...


res.write()

Description

res.write(data, doctype)

Writes data to the response.

Parameters

  • data (String, XML, or Object) - Writes data to the response. If a regular JavaScript Object is passed in, it will set the Content-Type of the response to "text/json" and write out the literal notation (JSON). Otherwise, the Content-Type will be "text/html", unless previously changed.
  • doctype (String, Optional) - Optional doctype to use. The default doctype can be set in app.properties.

Examples

var obj = {}
obj.name = "Test Object";
obj.value = "Test Value";
res.write(obj)

Here we are creating a regular JavaScript Object, and writing it to the response. The response will have a Content-Type of "text/json" and will look like this:

({name: "Test Object", value: "Test Value"})

Also See...


res.writeBinary()

Description

res.writeBinary(bytes)

Allows a user to write a byte array directly to the response.

Parameters

  • bytes (Array) - A Java byte Array to write to the response.

Also See...


res.writeln()

Description

res.writeln(string)

Writes string to the response and appends a platform dependent newline sequence.

Parameters string (String) - String to write to the response.

Also See...