java.io.IOException: Server returned HTTP response code: 500

后端 未结 6 2191
太阳男子
太阳男子 2020-12-14 19:04

I\'m facing this problem with Java. I want to get some HTML informations from a URL. This code was working for so long, but suddenly, it stopped working.

When I acce

6条回答
  •  没有蜡笔的小新
    2020-12-14 19:48

    HTTP status code 500 usually means that the webserver code has crashed. You need to determine the status code beforehand using HttpURLConnection#getResponseCode() and in case of errors, read the HttpURLConnection#getErrorStream() instead. It may namely contain information about the problem.

    If the host has blocked you, you would rather have gotten a 4nn status code like 401 or 403.

    See also:

    • How to use URLConnection to fire and handle HTTP requests?

提交回复
热议问题