http://post.naver.com/viewer/postView.nhn?volumeNo=13770913&memberNo=16714554&mainMenu=CULTURE
프로토콜(protocal) : http, jdbc, ...
호스트(host) : www.naver.com -> ***.***.***.***
포트(port) : 8000 (0 - 65535 : 0 - 1024 은 시스템에서 사용될 수 있으니 비권장, 5000 이후 포트번호나 10000번 이후 포트번호 권장)
: 80 : 웹의 기본 포트번호, 어떤 서비스를 사용할지
패스(path) : /test.do, 서비스에서 어떤 기능을 사용할지..
쿼리(query) : msg=hell, 기능을 사용할 때 필요한 데이터
소스
public static void main(String[] args) {
try {
URL url = new URL("http://www.naver.com:8000/test.do?msg=hello");
//URL url = new URL("http://post.naver.com/viewer/postView.nhn?volumeNo=13770913&memberNo=16714554&mainMenu=CULTURE");
System.out.println("getProtocol : " + url.getProtocol());
System.out.println("getHost : " + url.getHost());
System.out.println("getPort : " + url.getPort());
System.out.println("getPath : " + url.getPath());
System.out.println("getQuery : " + url.getQuery());
} catch (Exception e) {
e.printStackTrace();
}
}
결과
getProtocol : http
getHost : www.naver.com
getPort : 8000
getPath : /test.do
getQuery : msg=hello
Java - URL 쿼리를 post 방식으로 전송하기 (0) | 2018.10.02 |
---|---|
Java - 연결된 url로부터 데이터 읽기 (0) | 2018.10.02 |
Java - InetAddress (0) | 2018.10.02 |
Java - IO, finnaly문 정리 (0) | 2018.10.02 |
Java - IO, PrintWriter 사용 (0) | 2018.10.02 |
댓글 영역