How to refresh the jsp page after a given time(or interval)?

后端 未结 4 1226
遥遥无期
遥遥无期 2021-01-12 10:52

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?

相关标签:
4条回答
  • 2021-01-12 11:23

    You can try to add this:

    <META HTTP-EQUIV="Refresh" CONTENT="10">
    

    So this will refresh the page every 10 seconds

    0 讨论(0)
  • 2021-01-12 11:28

    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.

    0 讨论(0)
  • 2021-01-12 11:35

    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.

    0 讨论(0)
  • 2021-01-12 11:42

    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.

    0 讨论(0)
提交回复
热议问题