문제

Whenever a user logs in(into an app which I've been working on), he will be redirected to his home page, which needs to be refreshed one time. I have to write the code in .java file to basically refresh the browser.

How can this be achieved with java. I know it can be done using javascript, but I have to achieve the above in a .java file. Any ideas ???

도움이 되었습니까?

해결책

Just use code like this:

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

다른 팁

 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 

You want to set a cookie that will cause a page refresh.

For Java use this: http://www.rgagnon.com/javadetails/java-0180.html

For the homepage JavaScript use http://techpatterns.com/downloads/javascript_cookies.php

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top