sitelink1  
sitelink2  
sitelink3  
sitelink4  
sitelink5  
sitelink6  

JSP

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="java.io.*" %>
<%@ page import="java.net.*" %>
<%
    String tfs_url = "요청받을 서비스 페이지 (Servlet 또는 JSP)";
    String patchNums = "넘겨줄 값들(key=value&key=value 형태)";
    
    String stringToReverse = URLEncoder.encode(patchNums, "UTF-8");
    
    URL url = new URL(tfs_url);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setDoInput(true);
    connection.setDoOutput(true);

    connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    connection.setRequestMethod("POST");

    OutputStreamWriter osw = new OutputStreamWriter(connection.getOutputStream());
    try {
        osw.write("patchNums=" + stringToReverse);
        osw.flush();
    } finally {
        if (osw != null) osw.close();
    }

    BufferedReader brin = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    String resStr = null;
    StringBuffer resStrBuff = new StringBuffer();
    try {
          while ((resStr = brin.readLine()) != null) {
              resStrBuff.append(resStr);
          }
    } finally {
        if (brin != null) brin.close();
    }
    out.println(resStrBuff);
%>

 

 

 

Servlet

    URL url = new URL("http://[DOMAIN]:[PORT]/tfswit/updatewit?CMD=TFS_PATCH&PP_SEQ=1890");

    HttpURLConnection connection = (HttpURLConnection) url.openConnection();

    connection.setDoInput(true);

 

    BufferedReader brin = new BufferedReader(new InputStreamReader(connection.getInputStream()));

    String resStr = null;

    StringBuffer resStrBuff = new StringBuffer();

    try {

        while ((resStr = brin.readLine()) != null) {

            resStrBuff.append(resStr);

        }

    } finally {

        if (brin != null) {

            brin.close();

            brin = null;

            connection = null;

            url = null;

            resStr = null;

        }

    }

 

    String tfsPatch = null;

    if (resStrBuff != null)

        tfsPatch = resStrBuff.toString();

 

 

번호 제목 글쓴이 날짜 조회 수
263 JavaMail - 네이버 메일 수신하기(POP3) 황제낙엽 2018.08.20 1616
262 JavaMail - POP3로 메일 읽어오기 - 단순샘플 황제낙엽 2018.08.20 485
261 [HttpURLConnection, HttpsURLConnection] Response 로 받은 데이터가 압축되어 있는 경우(gzip, deflate) 황제낙엽 2018.08.16 695
260 [HttpURLConnection, HttpsURLConnection] 자바 Http / https 의 결과를 주고받을때 세션을 유지 황제낙엽 2018.08.12 554
259 [HttpURLConnection] 자바(Java) URL 접속 및 세션 관리 file 황제낙엽 2018.08.12 552
258 json-rpc 에서 한글 문제 황제낙엽 2018.08.08 511
257 org.apache.commons.io.FilenameUtils (getExtension) 황제낙엽 2018.04.01 1507
256 이미지 파일의 화면사이즈와 포맷(확장자) 구하기 황제낙엽 2018.04.01 774
255 File 을 다루기 위한 유틸 클래스 file 황제낙엽 2018.02.28 425
254 상수의 데이터 타입 황제낙엽 2018.01.26 574
253 Java에서 User-Agent 파써 사용하기 황제낙엽 2017.11.20 734
252 현재 월,일,시간,분,초 등등 가져오기 황제낙엽 2017.11.02 1109
251 Calendar, Date, Format, java.time 패키지 황제낙엽 2017.10.31 416
250 날짜, 시간 문자열 값으로 Date 오브젝트로 만들기 >> SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.US) 황제낙엽 2017.10.31 1882
249 시스템 속성(System Property) 클래스를 이용하여 jni 라이브러리 사용하기 황제낙엽 2017.09.22 359
248 Java 실행 옵션들 황제낙엽 2017.08.23 3643
247 HttpsURLConnection 을 사용한 SSL서버 접속 file 황제낙엽 2017.08.02 533
246 서버구동시 주기적으로 동작을 수행하는 스레드를 함께 실행하는 서블릿 황제낙엽 2017.08.02 473
» HttpURLConnection 사용 샘플( JSP , SERVLET ) 황제낙엽 2017.08.01 696
244 HttpURLConnection 사용하기 황제낙엽 2017.08.01 793