我们需要从WebSphere Liberty中使用Custom头部署的Application B中调用部署在WebSphere Application Server中的应用程序A.两台服务器位于同一个域但主机不同。我无法使用reponse.sendRedirect()
和window.location
,因为他们会创建新请求。 RequestDispatcher.forward
用于本地资源。
例如, 我有申请:https://host1.domain.com/LibertyApp1/index.jsp
这会加载一个JavaScript,我需要在host2.domain.com中调用WasApp1。
我的JavaScript看起来像这样:
function callWAS(token) {
var request = new XMLHttpRequest();
var path = "https://host2.domain.com/WasApp1/SimpleServlet";
request.open("POST",path,true);
request.setRequestHeader("Authorization",token);
request.send(null);
}
token是我需要在Authorization标头中设置的String。
当执行JavaScript时,它正在创建一个飞行前请求,POST
和OPTIONS
请求都提供状态200.但页面控件仍然使用LibertyApp1。我希望页面控件与WasApp1一起使用。有没有办法可以使用自定义的http请求标头将请求转发给WasApp1?