I have 2 machines running tomcat which are in lan.
Can I make a call from jsp in one machine to another jsp page in another machine
I have tried it as follows:
<%
RequestDispatcher rd=application.getRequestDispatcher("http://10.44.111.149:8080/stud/sample.jsp");
RequestDispatcher rd=application.getRequestDispatcher("/index.jsp");
rd.include(request,response);
%>
But it gave me the following error:
java.lang.IllegalArgumentException: Path http://10.44.111.149:8080/stud/sample.jsp does not start with a "/" character
Is there any way to do this.
您可以将客户端重定向到Internet上的任何URL(尽管不能使用getRequestDispatcher
进行重定向),但是处理该重定向的JSP将没有第一台机器生成的任何servlet / request / session上下文(除非您正在集群)具有跨服务器会话的Web服务器)。
RequestDispatcher is not intended for such an use. Instead you can use response.sendRedirect(...) from your server to the remote server as below
response.sendRedirect(remoteServerUrl);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.