用于刷新浏览器的Java代码

时间:2011-12-13 05:45:52

标签: java page-refresh browser-refresh

每当用户登录(进入我正在处理的应用程序)时,他将被重定向到他的主页,需要刷新一次。我必须在.java文件中编写代码来基本刷新浏览器。

如何用java实现这一目标。我知道它可以使用javascript完成,但我必须在.java文件中实现上述功能。有任何想法吗 ???

3 个答案:

答案 0 :(得分:2)

只需使用以下代码:

response.setHeader("Refresh", "0; URL=http://your-current-page");

答案 1 :(得分:1)

 response.setHeader("Refresh", "0; URL=" + request.getContextPath() + "/test.do?methodname=test&param=test"); 

Instaed of hardcoding the URL (URL=http://your-current-page). you can use below. 
request.getContextPath()
 will get respective ip address 

答案 2 :(得分:0)

您想要设置一个会导致页面刷新的Cookie。

对于Java,请使用:http://www.rgagnon.com/javadetails/java-0180.html

首页JavaScript使用http://techpatterns.com/downloads/javascript_cookies.php