You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Richard Suematsu <ri...@syncadd.com> on 2007/03/31 00:13:07 UTC

Servlet talking to servlet talking to servlet

Hi,

I have a situation where I have Servlet 1 doing a 
HttpClient.exec(PostMethod) to Servlet 2 doing a 
HttpClient.exec(PutMethod) to servlet 3.  So the PostMethed doesn't 
return until the PutMethod returns.  All are using the same instance of 
HttpClient.  I am NOT using the MultiThreadedHttpConnectionManager.  Is 
this supposed to work?

It works on Windows, but doesn't on Linux.  On linux, it freezes on the 
second call HttpClient.exec(PutMethod).  Should I be using the 
MultiThreadedHttpConnectionManager?  I think I should, but I don't know 
why it works on Windows.

-- 
Aloha,
Richard Suematsu
SynCaDD Systems, Inc.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: Servlet talking to servlet talking to servlet

Posted by Roland Weber <ht...@dubioso.net>.
Hello Richard,

> I have a situation where I have Servlet 1 doing a
> HttpClient.exec(PostMethod) to Servlet 2 doing a
> HttpClient.exec(PutMethod) to servlet 3.  So the PostMethed doesn't
> return until the PutMethod returns.  All are using the same instance of
> HttpClient.  I am NOT using the MultiThreadedHttpConnectionManager.  Is
> this supposed to work?

No it's not, if you mean that you are using SimpleHttpConnectionManager.
If your servlet is calling another servlet in the same servlet container,
you should use the Servlet API to pass on the request:

http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/RequestDispatcher.html

> It works on Windows, but doesn't on Linux.  On linux, it freezes on the
> second call HttpClient.exec(PutMethod).  Should I be using the
> MultiThreadedHttpConnectionManager?

Yes. Though it shouldn't freeze with the SimpleHttpConnectionManager.
Rather, the first connection should be terminated when it is allocated
a second time. You should be seeing warnings in the log. Are you sure
you are using the same version of HttpClient in both environments?
May there be differences in the servlet container's thread handling?

> I think I should, but I don't know why it works on Windows.

Pure luck. Or rather coincidence, because it is not luck
if buggy code _seems_ to work.

cheers,
  Roland



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org