String contextPath = browsersSwitched ? contextPath1 : contextPath2;
// We navigate to the home page on the second server, just to set the cookies
driver.navigate().to(new URL(contextPath));
driver.manage().deleteAllCookies();
driver.manage().addCookie(new Cookie("JSESSIONID", sid));
// Now we navigate for reals
driver.navigate().to(new URL(contextPath + "/" + address));
browsersSwitched = !browsersSwitched;