title: Accessing a URL using a loop
body: <p>I have created a web application, and hosted in on the server. Now I want to create a java program which will access (or "hit") the URL of my application in a loop, so that I can check how much load can my web application can handle. Also, the program should be able to tell me when the URL was successfully accessed, and when it wasn't.</p>
  
  <p>I tried executing it without using a loop:</p>
  
  <pre><code>try {
          URL url = new URL("https://example.com/");
          BufferedReader in = new BufferedReader(
                  new InputStreamReader(url.openStream()));
  
          String inputLine;
          while ((inputLine = in.readLine()) != null) {
              System.out.println(inputLine);
          }
          in.close();
      } catch (Exception e) {
          System.out.println("e: " + e.toString());
      }
  </code></pre>
  
  <p>But, I got this error:</p>
  
  <pre><code>e: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No  subject alternative DNS name matching example.com found.
  </code></pre>