title: How to set BeanShellPostProcessor script from java code instead from Jmeter GUI?
body: <p>I have requirement, where I need to add <code>BeanShellPostProcessor</code> programmatically preferably in java.</p>
  
  <p>Below is the sample code to add <code>BeanShellPostProcessor</code> to <code>JMX</code> and it is working.But I don't want to hard code the script (see the below code), script will change for each API test.
  How to write the <code>beanshell</code> script programmatically </p>
  
  <pre><code>String script = "if (prev.getResponseCode().equals(401) == true) { prev.setResponseOK();}";
  
          BeanShellPostProcessor bspp = new BeanShellPostProcessor();
          bspp.setProperty(TestElement.TEST_CLASS, BeanShellPostProcessor.class.getName());
          bspp.setProperty(TestElement.GUI_CLASS, TestBeanGUI.class.getName());
          bspp.setName("BeanShell PostProcessor");
          bspp.setProperty("resetInterpreter", false);
          bspp.setProperty("enabled", true);
          bspp.setProperty("script", script );
  
          HTTPSampleProxyHashTree.add(bspp);
  </code></pre>