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:
If widgetType=blue
, then I want all server-side requests to go to:
If widgetType=orange
, then I want all server-side requests to go to:
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.