Context

Context object is used to store and manage properties for a single execution flow (with or without HTTP request)

Version 3.x

Basic Usage

1
2
3
4
5
6
7
8
9
var context = require('core/v3/context');
var response = require('http/v3/response');

context.set("attr1", "value1");
var attr = context.get("attr1");

response.println("[Attribute]: " + attr);
response.flush();
response.close();

Definition

Functions


Function Description Returns
get(key) Returns the value per key from the context parameters string
set(key, value) Sets the value per key to the context parameters -

Compatibility

Rhino Nashorn V8
βœ… βœ… βœ…


Version 2.x

Basic Usage

1
2
3
4
5
6
7
8
9
10
11
12
/* globals $ */
/* eslint-env node, dirigible */

var context = require('core/context');
var response = require('net/http/response');

context.set("attr1", "value1");
var attr = context.get("attr1");

response.println("[Attribute]: " + attr);
response.flush();
response.close();

Definition

Functions


Function Description Returns
get(key) Returns the value per key from the context parameters string
set(key, value) Sets the value per key to the context parameters -

Compatibility

Rhino Nashorn V8
βœ… βœ… ❌
Edit