title: How to get latency, sample time, bytes and other such variables used in different listeners when using Java Request Sampler
body: <p>I am not able to capture to use the methods of HTTPSamplerResult.</p>
  
  <p>What should i do to get the Sample Time(ms), Bytes, Sent Bytes, Latency, connect time and other parameters.</p>
  
  <p>I am not able to get these details in the Listener : <strong>view Results in Table</strong> and other listeners as well.</p>
  
  <p>Can someone help me with this.
  I didn't get the implementation of how to set all the variables.</p>
  
  <p>Below is my code for my java request sampler.</p>
  
  <pre><code>public HTTPSampleResult runTest(JavaSamplerContext arg0)
  {
      HTTPSampleResult result = new HTTPSampleResult();
      //Below array contains the user id and password that comes with every chirp
      byte[] idpwd = new byte[]{38,85,115,101,114,78,97,109,101,61,101,82,101,103,38,85,115,101,114,80,97,115,115,119,111,114,100,61,97,98,99,49,50,51};
  
      //below we are converting the hex string coming as parameter to Byte Array.
      byte arr[] = toByteArray(arg0.getParameter("HEX"));
      //Below we are getting the lengths of both the arrays : idpwd &amp; arr
      int aLen = arr.length;
      int bLen = idpwd.length;
      ////////////////////////////////////////////////////////////////////
  
      //below we are initializing the byte array to contain both our hex string converted to byte array and the id-pwd.
      byte[] actual_Chirp = new byte[aLen+bLen];
  
      //Below we are concatenating both the arrays.
      //first we are adding the arr to the actual_chirp.
      //then we are adding the idpwd from the alen to blen.
      System.arraycopy(arr, 0, actual_Chirp, 0, aLen);
      System.arraycopy(idpwd, 0, actual_Chirp, aLen, bLen);
  
      //Here we we actually hit the meter service
      try
      { 
  
          URL obj = new URL(arg0.getParameter("URL"));
          HttpURLConnection con = (HttpURLConnection) obj.openConnection();
          con.setRequestMethod("POST");
          con.setDoOutput(true);
  
          OutputStream os = con.getOutputStream();
  
          result.sampleStart();
  
          /////////////////////////////////////////////////////////////////////////
          os.write(actual_Chirp);
          os.flush();
          os.close();
          ///////////////////////////////////////////////////////////////////////
  
  
  
          result.sampleEnd();
  
          result.setContentType(con.getContentType());
          result.setSamplerData(POST_URL);
  
  
  
          System.out.println(con.getContentType());
          System.out.println(result.getHTTPMethod());
          System.out.println(result.getRequestHeaders());
          System.out.println(Hex.encodeHexString(result.getResponseData()));
  
  
  
  
  
          result.setSuccessful(true);
  
          System.out.println(con.getResponseMessage());
  
  
  
      }
      catch(Exception E)
      {
      }
  
      //
  
      return result;
  
  }
  </code></pre>