2

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 ???

Anuj Balan
  • 7,629
  • 23
  • 58
  • 92
  • Java runs on the server. JavaScript runs in the browser. It shouldn't be that hard to figure out why it's easy to make JavaScript do what you want, but not Java. – Matt Ball Dec 13 '11 at 05:48
  • Are you talking about Java on the server side or client side? – Roman Dec 13 '11 at 05:49
  • Yea it is easy to do it in javascript, but I am trying to achieve the same through java(which, am not sure on how to) – Anuj Balan Dec 13 '11 at 05:50

3 Answers3

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 
Siva Harsha
  • 1,119
  • 1
  • 7
  • 5
1

Just use code like this:

response.setHeader("Refresh", "0; URL=http://your-current-page");
anubhava
  • 761,203
  • 64
  • 569
  • 643
0

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

Mikhail
  • 7,749
  • 11
  • 62
  • 136