java로 http로 웹 페이지 자료 취득 질문드립니다.

ourlord의 이미지


안녕하세요.

java로 http로 특정 웹페이지에서 자료를 취득하려는데 어떤 방법을 써야 할지 몰라서 질문을 드립니다.

현재 프로그램 구조는 다음과 같습니다.

BI05XXX.java

--자료 취득 대상자 검색

--인증 페이지 요청(인수 값으로 대상자 정보)
-HTTPXXX.java요청

--다운로드 메뉴 페이지 요청(인수 값으로 대상자 정보)
-HTTPXXX.java요청

--다운로드 데이터 요청(인수 값으로 대상자 정보)
-HTTPXXX.java요청

HTTPXXX.java

-- 요청시 대상자 정보를 기본으로 url작성 후에 아래의 공통 메소드 호출

private HttpEntity requestPost(String aStrUrl, List aLstParams)
{
HttpPost httppost = null;
HttpResponse response = null;
boolean retryFlg = true;
boolean excepFlg = true;
int retryCount = 1;

while(retryFlg){
try {
mLog.printLog(LEVEL.DEBUG, false, "REQUEST URL(" + retryCount + ") : " + aStrUrl);
mLog.printLog(LEVEL.DEBUG, false, "REQUEST METHOD : POST");
for (int i = 0; i < aLstParams.size(); i++) {
mLog.printLog(LEVEL.DEBUG, false, "PARAM INFO : %s : %s", aLstParams.get(i).getName(), aLstParams.get(i).getValue());
}

httppost = new HttpPost(aStrUrl);
httppost.setEntity(new UrlEncodedFormEntity(aLstParams, mStrDocomoEncoding));
response = mHttpClient.execute(httppost);

mIntStsCode = response.getStatusLine().getStatusCode();

if (mIntStsCode == HttpURLConnection.HTTP_OK) {
mLog.printLog(LEVEL.DEBUG, false, "REQUEST OK : %s", response.getStatusLine());
}else if(mIntStsCode == HttpURLConnection.HTTP_MOVED_TEMP) {
mLog.printLog(LEVEL.DEBUG, false, "REQUEST OK : %s", response.getStatusLine());
} else {
mLog.printLog(LEVEL.ERROR, false, "REQUEST FAIL.. : %s", response.getStatusLine());
return null;
}
} catch (Exception e) {
mLog.printLog(LEVEL.DEBUG, false, "Exception");
mLog.printLog(LEVEL.ERROR, true, "CB000193", e.getMessage());
mLog.printException(e);
excepFlg = false;
}
//EXECTION발생시、재시도
if ( excepFlg == false ) {
if( retryCount >= Integer.parseInt(mStrDocomoTimeOutReCnt) ) {
mLog.printLog(LEVEL.DEBUG, false, "POST의 재시도 오버");
return null;
//System.exit(255);
}else {
try {
mLog.printLog(LEVEL.DEBUG, false, "POST의 재시도 횟수(" + retryCount + ") SLEEP설정");
Thread.sleep(Integer.parseInt(mStrDocomoTempSleep) * 1000);
} catch (InterruptedException ie) {
mLog.printException(ie);
mLog.printLog(LEVEL.ERROR, false, "CB000193", ie.getMessage());
System.exit(255);
}
excepFlg = true;
retryCount++;
continue;
}
}
retryFlg = false;
}

return response.getEntity();
}

위에 같이 되어있습니다. 문제는 간혹 가다가 페이지가 응답이 없을때가 있어서 재시도를 하는 소스를 넣었지만 그래도 안되는 경우가 있더군요.

어쩔수 없이 인증부터 다시 해야 해결할 수 있을 것 같은데 사용자 정보를 유지한 상태에서 인증 페이지 요청에 관한 메소드를 부르는 방법에 대하여 궁금합니다.

재귀함수는 기본적으로 안된다고 하더군요.. 무한루프등으로 위험하기때문에...

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.