Novice GWT question: Parallel Post Requests

108 views
Skip to first unread message

LogicalGoetz

unread,
Apr 23, 2012, 5:20:34 PM4/23/12
to Google Web Toolkit
This may be a terribly novice question, but for each POST performed
by, say, a FormPanel, is there a subsequent HttpResponse generated by
the Servlet?

Obviously in standard situations this will play out as follows:
-client makes a POST request
-servlet handles the request
-servlet sends POST response
-client receives response

However, the situation I'm curious about is when something like this
occurs:
-client makes a POST request
-servlet handles the request
-client makes a POST request (this occurs a few times possibly)
-servlet handles these requests
-servlet generates responses
-client receives a series of responses (no guarantee on order)

From my current testing, it seems that if I have a FormPanel make
multiple POST requests while the servlet processes the requests, only
the first will ever generate a response. Is this the nature of Java
servlets, my client application (firefox), the http specification, or
possibly a coding blunder on my part?

Thank you in advance for any information,
Mike

Alan Chaney

unread,
Apr 24, 2012, 11:10:16 AM4/24/12
to google-we...@googlegroups.com
Interesting question... see comments below
for each post there should be a response = that's the http specification.

There is no limit in the java servlet spec to the number of simultaneous
requests. A server is normally expected to queue requests or reject them
("temporarily unavailable") but for each request there is still a
response - otherwise you'd get a timeout ("server not responding")

The servlet spec does provide alternative mechanisms for scheduling. A
good design will always assume that many requests can be concurrently
occurring and handle that accordingly - for example by using stateless
objects and transactional data stores. Avoid synchronous servlets like
the plague.

Either you are somehow *not* generating more than one post or you are
getting more than one response and overwriting the results.

Try:
1. watching the request/response with firebug or similar and do some
console logging of state in your client
2. Add some debugging output to the servlet to see whats happening there.

Then study the results and determine the causality! At least, that's
what I'd do.

HTH

Alan

Joseph Lust

unread,
Apr 24, 2012, 4:51:10 PM4/24/12
to google-we...@googlegroups.com
I've run into this exact problem before, but not while using GWT. I found that for XHR's, Post 1 must return before Post 2 can return. I'm not sure why this it, but it seems to be the case at least on FF and Chrome.

My use case was to:
  • Post 1 - start a long running task
  • Post 2 - Check on state of long running application (repeat on timer)
  • Post 1 finally returns.
I had to work around with setting a work queue in a database and then checking it with a cron job (it was PHP, so no persistent global synchronized lists like in Java), but I'd love to know why this works this way. I just assume it is some browser quirk.

Sincerely,
Joseph

kim young ill

unread,
Apr 25, 2012, 3:50:17 PM4/25/12
to google-we...@googlegroups.com
On Mon, Apr 23, 2012 at 11:20 PM, LogicalGoetz <digita...@gmail.com> wrote:
This may be a terribly novice question, but for each POST performed
by, say, a FormPanel, is there a subsequent HttpResponse generated by
the Servlet?

Obviously in standard situations this will play out as follows:
-client makes a POST request
-servlet handles the request
-servlet sends POST response
-client receives response

However, the situation I'm curious about is when something like this
occurs:
-client makes a POST request
-servlet handles the request
-client makes a POST request (this occurs a few times possibly)
-servlet handles these requests
-servlet generates responses
-client receives a series of responses (no guarantee on order)

From my current testing, it seems that if I have a FormPanel make
multiple POST requests while the servlet processes the requests, only
the first will ever generate a response.

AFAICT, if u have a (html) form (which wrapped by a formpanel), this will be posted only once to server , for which u'll get a response, this form in this case will not be available for u anymore on the client side to do a re-post.

or did i misunderstanding when u says "a FormPanel make
multiple POST requests " ?



 
 Is this the nature of Java
servlets, my client application (firefox), the http specification, or
possibly a coding blunder on my part?

Thank you in advance for any information,
    Mike

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Joseph Lust

unread,
Apr 25, 2012, 6:08:31 PM4/25/12
to google-we...@googlegroups.com
However, keep in mind that GET requests are quite limited. For example, IE cannot handle a URL longer than 2083 characters. Thus, not very much information can be serialized into a URL. Hence, most forms are usually POST'd, not GET'd.


Joe
Reply all
Reply to author
Forward
0 new messages