How can I refresh the page my browser is showing with JSP?

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.


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:

	int i=0;
	String ii = (String) session.getValue("count");
      if (ii!=null) { 
		i = Integer.parseInt(ii);
		out.println("<h1>Counter is: "+i+"<h1>" );
      session.putValue("count",new Integer(i).toString());
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact