Writing attributes (write)

Writing an attribute is quite similar to reading one, except that the request takes an additional value element.

GET write request

Writing an attribute with a GET request, an URL with the following format has to be used:

<base url>/write/<mbean name>/<attribute name>/<value>/<inner path>
Table 1. GET Write Request
Part Description Example

<mbean name>

MBean’s ObjectName

java.lang:type=ClassLoading

<attribute name>

Name of attribute to set

Verbose

<value>

The attribute name to value. The value must be serializable as described in Request parameter serialization.

true

<inner path>

Inner path for accessing the parent object on which to set the value. (See also Paths). Note, that this is not the path to the attribute itself, but to the object carrying this attribute. With a given path it is possible to deeply set a value on a complex object.

For example, you can set the garbage collector to verbose mode by using something like

http://localhost:8080/jolokia/write/java.lang:type=Memory/Verbose/true

POST write request

The keys which are evaluated for a POST write request are:

Table 2. POST Write Request
Key Description Example

type

write

mbean

MBean’s ObjectName

java.lang:type=ClassLoading

attribute

Name of attribute to set

Verbose

value

The attribute name to value. The value must be serializable as described in Request parameter serialization.

true

path

An optional inner path for specifying an inner object on which to set the value. See Paths for more on inner paths.

Write response

As response for a write operation the old attribute’s value is returned. For a request

http://localhost:8080/jolokia/write/java.lang:type=ClassLoading/Verbose/true

you get the answer (supposed that verbose mode was switched off for class loading at the time this request was sent)

{
  "request": {
    "mbean": "java.lang:type=ClassLoading",
    "attribute": "Verbose",
    "type": "write",
    "value": "true"
  },
  "value": false,
  "status": 200,
  "timestamp": 1702455595
}

The response is quite similar to the read operation except for the additional value element in the request (and of course, the different type).

This page was built using the Antora default UI. The source code for this UI is licensed under the terms of the MPL-2.0 license. | Copyright © 2010 - 2023 Roland Huß