2012-08-10 87 views
0

的我有一个的login.jsp重定向这个语法的index.jsp:response.sendRedirect是不跟踪IP

response.sendRedirect("index.jsp"); 

,当我访问本地主机服务器:测试8080应用程序工作正常。 当我从另一台PC远程浏览时,我需要该服务器地址(如xxx.xxx.xxx.xxx:8080),重定向将我发送给localhost:8080/index.jsp,当然这不在本地机。如果我写了类似

response.sendRedirect("xxx.xxx.xxx.xxx:8080/index.jsp"); 

然后浏览器丢失会话变量,我不想要。 如何解决这个问题?

回答

0

试试这个

response.sendRedirect("/yourWebContext/index.jsp"); 

这将工作

xxx.xxx.xxx.xxx:8080/index.jsp

失去会话可能是因为浏览器没有按” t发送它已经收到的cookie与不同的域名

2

尝试使用reque stDispatcher.forward()代替response.sendRedirect()..

这将工作...