title: Why do I get an error 500 when I send a GET request?
body: <p>I am trying to send a simple GET request, as it is explained here : <a href="https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests">Using java.net.URLConnection to fire and handle HTTP requests</a></p>
  
  <p>The web page I'm pointing to is : <a href="https://e-campus.hei.fr/ERP-prod/" rel="nofollow noreferrer">https://e-campus.hei.fr/ERP-prod/</a></p>
  
  <p>And I get this HTTP500 error :</p>
  
  <pre><code>Exception in thread "main" java.io.IOException: Server returned HTTP response code: 500 for URL: https://e-campus.hei.fr/ERP-prod/
  at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
  at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
  at GetWebPage.main(GetWebPage.java:14)
  </code></pre>
  
  <p>Why do I receive this error for this page ? The code i wrote will return me the source code of any other web page...</p>
  
  <p>My code : </p>
  
  <pre><code>public class GetWebPage {
  public static void main(String args[]) throws MalformedURLException,
          IOException {
      URLConnection connection = new URL("https://e-campus.hei.fr/ERP-prod/").openConnection();
      connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401");
      InputStream response = connection.getInputStream();
  
      InputStreamReader isr = new InputStreamReader(response);
      BufferedReader reader = new BufferedReader(isr);
      StringBuilder sb = new StringBuilder();
      String line = "";
      while ((line = reader.readLine()) != null) {
          sb.append(line + "\n");
      }
      System.out.println(sb.toString());
  
  }
  </code></pre>
  
  <p>}</p>