YouTip LogoYouTip

Jsp Auto Refresh

# JSP Auto Refresh Imagine if you wanted to live-stream a game score, or the real-time status of the stock market, or the current foreign exchange allocation, how would you implement it? Obviously, to achieve this kind of real-time functionality, you would have to refresh the page regularly. JSP provides a mechanism to make this task simple, allowing the page to be automatically refreshed at timed intervals. The simplest way to refresh a page is to use the `setIntHeader()` method of the response object. The signature of this method is as follows: public void setIntHeader(String header, int headerValue) This method notifies the browser to refresh after a given time, in seconds. * * * ## Page Auto Refresh Program Example This example uses the `setIntHeader()` method to set the refresh header, simulating a digital clock: Auto Refresh Example

Auto Refresh Example

Save the above code in a file named `main.jsp` and access it. It will refresh the page every 5 seconds and display the current system time. The result is as follows: Auto Refresh ExampleCurrent Time is: 6:5:36 PM You can also try writing a more complex program yourself.
← Jsp Sending EmailJsp Hits Counter β†’