2012-06-27 4 views
0

두 개의 웹 응용 프로그램, 태피스 트리 응용 프로그램 및 간단한 웹 응용 프로그램 (servelt)이 있습니다. 태피스 트리 appli에서, 나는 양식을 가지고 있고, 그것이 보내질 때, 나는 apache의 httpClient를 사용하여 appli에 정보를 보내기 위해 httpClient를 호출한다. 이 같은 Tapestry, 다른 응용 프로그램에서 처리 요청

void onSubmitFromForm() { 

    try { 

     HttpClient client = new DefaultHttpClient(); 
     HttpPost post = new HttpPost("http://localhost:8080/appli2/recep"); 
     post.setHeader("referer", "http://localhost:9090/app1/start"); 

     List<NameValuePair> param = new ArrayList<NameValuePair>(); 

     param.add(new BasicNameValuePair("_data", getData()); 

     post.setEntity(new UrlEncodedFormEntity(param)); 

     HttpResponse response = client.execute(post); 
        response ????? 
      } catch (Exception e) { 

     e.printStackTrace(); 

    } 

} 

그리고 간단한 웹 어플리 내 servelt의 레셉의

(2) 내가 할 같은

protected void doPost(HttpServletRequest request, 
     HttpServletResponse response) throws ServletException, IOException { 
    // TODO Auto-generated method stub 
    try { 
     HttpClient client = new DefaultHttpClient(); 
     HttpPost post = new HttpPost(request.getHeader("referer")); 

     post.setHeader("p",getP()); 

     client.execute(post); 


    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

} 

그래서, 내 레셉의 reviev의 내 양식의 데이터 만 it'cannot가 대응 방법 아래와 같이 , 단순한 웹 응용 프로그램에서 테이퍼 형 응용 프로그램이 매개 변수 'P'를받을 수 있습니까? 감사합니다.

답변

0

올바른 경우 Tapestry 내의 양식 제출에서 수신 한 양식 데이터를 다른 애플리케이션에서 실행중인 서블릿으로 POST하기 위해 태피스 트리 애플리케이션이 필요합니다.

이것이 원하는 경우 누락 된 부분은 요청을 처리하고 서블릿에서 응답을 구성하는 것입니다. 귀하의 태피스 트리 페이지와 서블릿 모두 POST하기 때문에 당신의 HttpClient가 처리 할 응답을 구성하지 않습니다.

public void doPost(HttpServletRequest request, 
    HttpServletResponse response) 
     throws ServletException, IOException 
    { 
    response.setContentType("text/plain"); 
    PrintWriter out = response.getWriter(); 

    out.println(getP()); 
    out.close(); 
    } 

그리고 당신의 tapesty 양식 처리기에서 응답을 처리 : 당신이 할 수 서블릿에서

.

+0

예 괜찮습니다. 감사합니다. – FiesAtoS

관련 문제