Skip to content

JSR223 PostProcessor

Configure the JMeter JSR223 PostProcessor post-processors: properties, defaults, and practical usage notes for building reliable load tests.

Difficulty
intermediate
Guide type
reference
Estimated read time
2 min read
Last verified version
Verified JMeter 5.6

Part of the Post-Processors category. Also documented in context in the full Component Reference.

TL;DR: the JSR223 PostProcessor runs Groovy code right after its parent sampler completes — the go-to spot for extraction logic too complex for the JSON or Regular Expression Extractor (nested conditionals, multi-step parsing, custom validation).

The JSR223 PostProcessor allows JSR223 script code to be applied after taking a sample.

NameRequiredDescription
NameNoDescriptive name for this element that is shown in the tree.
LanguageYesThe JSR223 language to be used
ParametersNoParameters to pass to the script. The parameters are stored in the following variables: - Parameters - string containing the parameters as a single variable - args - String array containing parameters, split on white-space
Script fileNoA file containing the script to run, if a relative file path is used, then it will be relative to directory referenced by “user.dir” System property
Script compilation cachingNoUnique String across Test Plan that JMeter will use to cache result of Script compilation if language used supports [Compilable](https://docs.oracle.com/javase/8/docs/api/javax/script/Compilable.html) interface (Groovy is one of these, java, beanshell and javascript are not) :::note See note in JSR223 Sampler Java System property if you’re using Groovy without checking this option :::
ScriptYes (unless script file is provided)The script to run.

Before invoking the script, some variables are set up. Note that these are JSR223 variables - i.e. they can be used directly in the script.

  • log - (Logger) - can be used to write to the log file
  • Label - the String Label
  • FileName - the script file name (if any)
  • Parameters - the parameters (as a String)
  • args - the parameters as a String array (split on whitespace)
  • ctx - (JMeterContext) - gives access to the context
  • vars - (JMeterVariables) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object()); vars.getObject("OBJ2");
  • props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");
  • prev - (SampleResult) - gives access to the previous SampleResult (if any)
  • sampler - (Sampler)- gives access to the current sampler
  • OUT - System.out - e.g. OUT.println("message")

For details of all the methods available on each of the above variables, please check the Javadoc

  • prev (the SampleResult) gives you prev.getResponseDataAsString(), headers, response code, and timing — you rarely need to re-parse anything the built-in extractors already exposed.
  • Anything you vars.put(...) here is visible to later samplers in the same thread, not earlier ones — order in the test tree matters.
  • If you’re just pulling one JSON field, reach for the JSON Extractor first; scripting adds maintenance cost that’s only worth it for genuinely custom logic.
  • Exceptions here don’t automatically fail the sample — catch and call prev.setSuccessful(false) (or similar) if a parsing failure should count as a test failure.
On this page