aspose file tools*
The moose likes Struts and the fly likes Overcoming limit of 2 HTTP requests in IE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Overcoming limit of 2 HTTP requests in IE" Watch "Overcoming limit of 2 HTTP requests in IE" New topic
Author

Overcoming limit of 2 HTTP requests in IE

Don Blodgett
Ranch Hand

Joined: Jan 09, 2006
Posts: 61
I am trying to find a way of overcoming the limit of 2 concurrent HTTP requests (using AJAX technique, the result would be JSON). I am able to do this in the client side JS by delaying a short period to collect a queue of requests, then submit them all as a single request. The returned result would be a JSON array with each of the responses for each request. The reasoning behind wanting to do this is to increase performance by limiting the number of HTTP requests that are needed. The number of concurrent request can range from 2-5+, which is why I would like to do this and building it into the underlying architecture would make things much easier to manage as opposed to manually combining various requests, which would become more and more difficult as the project expands.

I am using Struts 2, which I am fairly new to, and I have looked at chaining, but it doesn't appear that it would allow me to build a queue of results. I guess the simplest way of putting it is, is there any way to get the results of an action by calling that action from another action?

Thanks for any assistance.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The <s:action...> tag does this from the JSP side.

I'll add that IIRC this was an HTTP spec issue, and other browsers besides IE < 8 do the same thing. I'm not sure what the best strategy would be in S2 w/o giving it more thought.
Don Blodgett
Ranch Hand

Joined: Jan 09, 2006
Posts: 61
Thanks for the response, the s:action tag is just what I am looking for. I have run into a bit of a problem using it though. I am not sure how I can get values from a scriptlet to dynamically call actions. If I try to dynamically call the action, based on a parameter that I send it doesn't call the action, but if I hard code the action name it will call it. I have tested to make sure that reqt is getting the correct value. My guess is that my syntax is not correct and %{reqt} is seen as an empty string? This is the code I have:

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You are walking down a path that can only lead to tears. Turn back now.

To answer your question: in order to use an OGNL expression the variable has to be either in a JEE scope or on the value stack. It's the same as with JSP EL: a scriptlet variable isn't automagically scoped, you have to *put* it in a scope. OGNL can access JEE scoped vars, however, so just putting it in a scope should work. Or you could use tags all the way 'round and eliminate the scriptlet altogether.

All that said, there has *got* to be a better way, whether by exposing the functionality through services and serializing to JSON (like via the JSON plugin or something) or *anything* but this.
Don Blodgett
Ranch Hand

Joined: Jan 09, 2006
Posts: 61
Thanks for the heads up, but so that I am understanding you correctly, where do you see the dragons? Is it the use of the scriptlet, if so, I agree, and I am only using that to try and put together a POC to see if this would work at all. Or is it the use of the JSON without using some sort of JSON framework? I do plan to use the framework provided by JSON.org. Or is there something else that you see that is just not right?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The scriptlet and the ad-hoc way of getting all the results necessary. That kind of stuff really belongs somewhere besides the view layer--how best to do that really depends on the specific usecase.
Don Blodgett
Ranch Hand

Joined: Jan 09, 2006
Posts: 61
I have rethought this a bit and I now have everything in a servlet and using RequestDispatcher.include(req, res), but it is not executing the action that I am setting the dispatcher to. I don't get any errors from it, it just doesn't execute it, no output, nothing.

If I set the dispatcher to a static resource, it returns that just fine. Is this method simply not capable to executing an action? If so, is there a method that can execute an action?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

AFAIK request dispatchers can only include servlet resources (JSPs, servlets, etc.) but that might be partially configurable at the server level--I know there's something in web.xml... hmm, that might be for forwards and interceptors though.
 
Consider Paul's rocket mass heater.
 
subject: Overcoming limit of 2 HTTP requests in IE