commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <>
Subject RE: [httpclient] question
Date Sun, 12 Oct 2003 15:07:36 GMT
Privet Alexey,

One needs to remember that HTTP protocol has been designed to be
stateless. (HTTP cookies were a rather poor attempt to add state
management capabilities later on). Therefore HTTP protocol is not the
best match for the type of applications like yours. This said, with a
little bit of extra efforts, the solution to the problem you described
can be devised using plain-vanilla HTTP. 

You might consider doing the following:
- Client submits a request to the server
- Server initiates an HTTP session, spawns a worker thread responsible
for processing the request, and stores the reference to that thread in
the session object
- Server sends back the client some sort of 'acknowledgement' response.
- The client receives the 'acknowledgement' response and retrieves the
session id from it.
- The client polls the server if the worker thread is done processing
the request associated with the given session id.
- The server sends the client some sort of process status.
- If the worker process is reported as done, the client sends the
request to retrieve the results
- The server passes the results onto the client
- The client is happy

Just an idea


On Sun, 2003-10-12 at 15:16, Alexey Buistov wrote:
> Hello Oleg!
> I've reinvestigated the problem and found that you're right. The response is being returned,
> but my problem still remains :(
> How should I implement the following using HttpClient?
>  1) send a business-request to server (no problem)
>  2) server returns confirmation response: I've just got your request and going to process
it. Standby! (no problem)
>  3) server processes that request and _notifies_ the client: Done processing successfully.
(that's where I've stuck. The old implementation I try to get rid of uses some kind of socket
observer which queries the socket from time to time and finally gets the server notification.
Is this doable using HttpClient?)
> Alexey
> -----Original Message-----
> From: Oleg Kalnichevski []
> Sent: Sunday, October 12, 2003 12:48 PM
> To: Jakarta Commons Users List
> Subject: Re: [httpclient] question
> Hi Alexey,
> Unless I am missing something, there is absolutely nothing you need to
> change in your code. 
> >         HttpClient client = new HttpClient();
> >         HostConfiguration hc = new HostConfiguration();
> >         hc.setHost("localhost", 1010);
> >         client.setHostConfiguration(hc);
> >         PostMethod post = new PostMethod();
> >         post.setRequestBody(requestBody);
> >         client.executeMethod(post);
> > 
> HTTP is a request/response oriented protocol by definition. HttpClient
> will not return from executeMethod until it gets a response from the
> server or a socket read timeout occurs (which is off per default).
> Httpclient will continue listening on the socket at until it receives a
> response status line and a number of headers from the target server. 
> Oleg
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message