I would like to refresh/reload my jsp page after a certain time interval. Consider the time interval is of 5 minutes.
How can achieve it?
You can try to add this:
<META HTTP-EQUIV="Refresh" CONTENT="10">
So this will refresh the page every 10 seconds
You can use public void setIntHeader(String header, int headerValue)
response.setIntHeader("Refresh",300)
This method sends back header "Refresh" to the browser along with an integer value which indicates time interval in seconds.
Or you can use javascript to do this:
<script type="text/javascript">
setTimeout(function(){
location = ''
},60*1000)
</script>
setTimeout
will reload the page after a specified number of milliseconds, hence 60 * 1000 = 1m.
In jsp add
<%
response.setIntHeader("Refresh", time_in_second); //in your case 60*5=300 (for 5 min)
%>
If you want to do it without using java code then Rahul Tripathi
solution is the best as html tag will work perfectly in jsp.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With