简体   繁体   English

response.sendRedirect不跟踪ip

[英]response.sendRedirect doesn't keep track of ip

i have a redirect on login.jsp to index.jsp with this syntax: 我使用以下语法将login.jsp重定向到index.jsp:

response.sendRedirect("index.jsp");

on the server when I'm accessing on localhost:8080 testing the application it works fine. 在我访问localhost时服务器上:8080测试应用程序它工作正常。 when I'm browsing remotely from another PC, and i need that server address (like xxx.xxx.xxx.xxx:8080) that redirect sends me to localhost:8080/index.jsp which of course doesn't exist on local machine. 当我从另一台PC远程浏览时,我需要该服务器地址(如xxx.xxx.xxx.xxx:8080)重定向将我发送到localhost:8080 / index.jsp当然在本地机器上不存在。 If i write something like 如果我写的东西像

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

then the browser loses the session variables, which i do not want. 然后浏览器丢失了我不想要的会话变​​量。 how to solve this? 怎么解决这个?

Try using requestDispatcher.forward() instead of response.sendRedirect().. 尝试使用requestDispatcher.forward()而不是response.sendRedirect()..

This will work... 这将有效......

Try this 尝试这个

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

this will work 这会奏效

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

looses the session may be because browser doesn't send the cookie it has recieved for the with different domain name 丢失会话可能是因为浏览器没有发送已收到的具有不同域名的cookie

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM