質問

I understand that with GWT RequestFactory, server-side calls are all made to a RequestFactoryServlet. I'd like to write a GWT application (using RequestFactory) that looks to a cookie to determine which base URL all server-side calls are made to.

So, I'd have 3 different WAR files deployed to 3 different Tomcat instances living on 3 different physical servers, mapped to 3 different IP addresses (URLs). Each WAR would have a RequestFactoryServlet defined and would be capable of servicing requests from the same GWT client.

But, on the client-side, if a widgetType cookie has a value of red, I want all server-side requests to go to:

http://red.example.com/RequestFactoryServlet#doGet

If widgetType=blue, then I want all server-side requests to go to:

http://blue.example.com/RequestFactoryServlet#doGet

If widgetType=orange, then I want all server-side requests to go to:

http://orange.example.com/RequestFactoryServlet#doGet

So, in summary, the client-side cookie (widgetType) determines which RequestFactoryServlet on which WAR/server/URL the HTTP requests get sent to and processed by.

Is this possible? If not, why and is there anything that I can do here? If it is possible, how is it possible (what code/techniques/etc do I need to utilize)? Thanks in advance!

役に立ちましたか?

解決

Same-Origin potential issues put aside, all you need is to initialize your RequestFactory with a custom RequestTransport. The easiest is to extend DefaultRequestTransport and initialize its setRequestUrl depending on the cookie value.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top