일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- resource
- Source
- plugin
- 줄바꿈 문자
- import
- 단축키
- IntelliJ
- web.xml
- ssh
- GIT
- profile
- vscode
- context
- maVen
- grep
- port
- Windows
- find
- VirtualBox
- netsh
- tomcat
- Windows 10
- 네트워크
- JavaScript
- xargs
- Quartz
- Mac
- bash
- lsof
- Eclipse
- Today
- Total
develog
GET, POST 전송 본문
public void sendGet() throws Exception {
System.out.println(">> sendGet()");
String requestURL = "http://testdomain.com/test.jsp?enc_id=AA&enc_pw=BB";
URL url = new URL(requestURL);
URLConnection urlConn = url.openConnection();
urlConn.setUseCaches(false);
urlConn.setDoInput(true);
urlConn.setDoOutput(false);
BufferedReader br = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
}
public void sendPost() throws Exception {
System.out.println(">> sendPost()");
String requestURL = "http://testdomain.com/test.jsp";
URL url = new URL(requestURL);
URLConnection urlConn = url.openConnection();
urlConn.setUseCaches(false);
urlConn.setDoInput(true);
urlConn.setDoOutput(true);
OutputStreamWriter osw = new OutputStreamWriter(urlConn.getOutputStream());
osw.write("&enc_id=CC");
osw.write("&enc_pw=DD");
osw.flush();
osw.close();
BufferedReader br = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
}
'Dev > Java' 카테고리의 다른 글
Collection List<Map> sort (0) | 2013.05.16 |
---|---|
Java API for RESTful Web Services (0) | 2013.05.15 |
REST Tutorial (0) | 2013.05.13 |
자바 web to web 통신 (0) | 2013.05.07 |
synchronized (0) | 2013.03.17 |