If you look closely at the fine print inside a Pre Processor or Post Processor, you will see a list of Jmeter variables which are available inside a Jmeter thread:
These variables are specific to each thread, so they should not be considered global variables. In this post we will explore the VARS variable, which is a Jmeter thread class. The most commonly used methods of this class are PUT and GET.
There are a number of ways to initialize the variable. In this example I have created a placeholder variable called “myValue” inside the UDV:
To set the current value of the variable, use the PUT method:
String newValue = "NewNewNew"; vars.put("myValue", newValue);
When using the PUT method, this will overwrite any previous value that was stored in that variable.
Instead of using a placeholder variable, you can also initialize a VARS variable inside an Extractor or Post Processor element:
Once the value of VARS is set, you can use this variable in your requests like this:
To access the current value of VARS, use the GET method:
String currValue = vars.get("myValue"); log.info("This is the stored value = " + currValue);
Remember that these variables are thread specific, so the values can be different inside each thread. Conversely they can also be the same.