写一段java主动发送请求的示例代码

String url = "http://example.com/example.php";try { URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection();

// optional default is GET con.setRequestMethod("GET");

//add request header con.setRequestProperty("User-Agent", USER_AGENT);

int respon

你可能感兴趣的:(servlet)