Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can a http response be delayed?

843842Aug 29 2008 — edited Aug 31 2008
Hi,
I have a "simple" problem to solve but I am new to J2EE so I hope to find someone who has already faced with this problem.
I know a servlet can receive an http request from a client and prepare the response. The response will be sent as soon as the servlet returns. The same servlet serves the requests of many users, so if there are 100 users requesting for a servlet I guess the requests are queued and there will be a response outcoming the web-server for each request in the same order.
Please correct me if I say wrong things.
Now I would like to write a java code that receives the request but waits for a trigger event to send the response, without blocking other users.
I mean, a user sends a request, a servlet should forward the request to a thread (what else?) and exit without sending any response. The thread (I thought about a thread for each user) will wait for a trigger event and ONLY if the event happens the response will be sent to the requesting client.
In the meantime other users can send their requests and receive their response when their trigger events has happened.

1. Can J2EE technology allow me to do that?
2. How can I let the thread send the response to the right client?
3. Http packets do not contain the info about the client, how can I trigger the sending of the response?

I had a look to pushlet and comet but the problem I have seems to me different from let the server start a communication with a client. In my case the paradigm request-response is kept but the response is delayed. Of course the time-out should be increased (I have read that time out is settable in the client).
To be more clear I'm adding two examples:
1. one client (an applet) sends its request, the server receives the http packet and it will start a timer of 5 sec. Only when the timer expires the response will be sent. In the meantime other clients perform their requests and they all will be answered after 5 secs from their request (because there is a timer for each request).

2. the trigger is the number of requests received: if the server receives 10 requests from 10 clients then all the 10 clients will receive the response. If the server receives less of 10 requests in the time out period there will be issued a time-out error.

Please could you help me?
Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 28 2008
Added on Aug 29 2008
2 comments
1,472 views