I am trying to send a simple GET request, as it is explained here : Using java.net.URLConnection to fire and handle HTTP requests
The web page I'm pointing to is : https://e-campus.hei.fr/ERP-prod/
And I get this HTTP500 error :
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)
Why do I receive this error for this page ? The code i wrote will return me the source code of any other web page...
My 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());
}
}