How can I refresh the page my browser is showing with JSP?
Created May 4, 2012
Govind Seshadri You can use a META tag with an HTTP-EQUIV attribute
to control the action of browsers, by setting the HTTP headers. The
"Refresh" value can be used to specify a delay in seconds before the browser
automatically reloads the document. Optionally, you can also specify an alternative URL to load.
For example, the following tag loads the page foo.html after 5 seconds.
<META HTTP-EQUIV="Refresh" CONTENT="5;URL=http://www.somehost.org/foo.html">
To cause a reload on the same resource, don't specify the alternative URL. The following program demonstrates a running counter where the reload is controlled by the client:
<html> <META HTTP-EQUIV="Refresh" CONTENT="3"> <body> <% int i=0; String ii = (String) session.getValue("count"); if (ii!=null) { i = Integer.parseInt(ii); out.println("<h1>Counter is: "+i+"<h1>" ); i++; } session.putValue("count",new Integer(i).toString()); %> </body> </html>